Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: git with alias to external command



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