Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion for command-not-found "commands"
- X-seq: zsh-users 17186
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Completion for command-not-found "commands"
- Date: Tue, 24 Jul 2012 08:49:39 -0700
- In-reply-to: <alpine.LNX.2.01.1207232334460.27115@hp.internal>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <alpine.LNX.2.01.1207232334460.27115@hp.internal>
On Jul 24, 12:08am, Benjamin R. Haskell wrote:
}
} The very-short version of my question is: How can I dynamically get
} completion for `git rm` when what I've typed on the commandline so far
} is `grm`? ("dynamically" meaning without defining a bunch of compdef's
} up front.)
You probably want to write a completer function to insert into your
"completers" style. This is a crude version but mostly works:
_check_for_git_alias () {
[[ $words[1] = g* ]] || return 1
local al=${words[1]#g}
if valid_git_alias $al || valid_git_command $al
then
words[1]=(git $al)
((++CURRENT))
_normal
else
return 1
fi
}
zstyle ':completion:*' completer _check_for_git_alias \
whatever you already had for this style goes here
Obviously there are a bunch more tests you can do to figure out whether
it's even reasonable to treat $words[1] as a git alias or command, and
you may want to try this in some other ordering of the zstyle rather
than right at the beginning, but hopefully this gets you started.
--
Barton E. Schaefer
Messages sorted by:
Reverse Date,
Date,
Thread,
Author