From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Completion for command-not-found "commands"
Date: Tue, 24 Jul 2012 08:49:39 -0700 [thread overview]
Message-ID: <120724084939.ZM6427@torch.brasslantern.com> (raw)
In-Reply-To: <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
prev parent reply other threads:[~2012-07-24 15:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-24 4:08 Benjamin R. Haskell
2012-07-24 15:49 ` Bart Schaefer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=120724084939.ZM6427@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).