Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: git with alias to external command
- X-seq: zsh-workers 42752
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh hackers' list <zsh-workers@xxxxxxx>
- Subject: PATCH: git with alias to external command
- Date: Tue, 8 May 2018 17:06:12 +0100
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180508160616euoutp01a8065a335f74bd6bbdd582aa2cb96a02~stv4ev6ee2147721477euoutp01d
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1525795576; bh=0KNUQ/YfxXygs0GOX3Acpr9XvMNNNz7bQkxigCSMvdc=; h=Date:From:To:Subject:References:From; b=hoNyc9Z8uf8H5BDqqEl89uV2cLaoctARmcUiTu/+09oYoa9ilfdsTQ5qZbMgKyRY0 B8Ff+EwOSu337qWbDGoCeGt5f3bDSAwjElxkzWmHB58cbEKEeO+c7UoddYDuqT1ynC /VZw7nDJzKwKpi5xBHbMuMEKypX+Vaa0+cLcn8qs=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: SCSC
- References: <CGME20180508160614eucas1p11b9392c4bbca84a60656e8cf2c0f0d81@eucas1p1.samsung.com>
This is supposed to help with completion after something like "git bs"
where bs is defined by:
git config --global alias.bs '!git_branch_stack.rb'
Now completion after "git bs" is (more) like completion after
"git_branch_stack.rb". Strictly, I suppose we should cd to the root
directory of the repository.
The only possible problem I could see was that it's currently possible
to define a function 'git-!git_branch_stack.rb' to handle this, so I
made sure that wasn't broken (if anyone worked out this was the way to
do it before this change, they get lots of points, but unfortunately the
points aren't actually worth anything).
This doesn't use the style for a fallback, since the alternative --- an
error saying this is is an unknown subcommand --- isn't appropriate
(unless the '!thing' came from the user entering it directly on the
command line, but that didn't seem a particularly useful case to test
for --- if anyone felt the need to be scruplous, we could add a flag
saying this was an expanded alias).
pws
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index f6cec8b..21ba657 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -7758,7 +7758,10 @@ _git() {
curcontext=${curcontext%:*:*}:git-$words[1]:
(( $+opt_args[--git-dir] )) && local -x GIT_DIR=$opt_args[--git-dir]
if ! _call_function ret _git-$words[1]; then
- if zstyle -T :completion:$curcontext: use-fallback; then
+ if [[ $words[1] = \!* ]]; then
+ words[1]=${words[1]##\!}
+ _normal && ret=0
+ elif zstyle -T :completion:$curcontext: use-fallback; then
_default && ret=0
else
_message "unknown sub-command: $words[1]"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author