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

A stab at better git-show completion



I decided i want to get very confused, so i decided to try and make
git-show completion allow
completing of the form commit:path/file where the path/file part
depends on what commit you
typed. Somehow i succeeded. (the [1,-2] is for removing the trailing colon)

http://git.mikachu.ath.cx/?p=zsh-cvs.git;a=commitdiff_plain;h=gitshow

--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1010,11 +1010,25 @@ _git-show-ref () {

 (( $+functions[_git-show] )) ||
 _git-show () {
+  local curcontext=$curcontext state line
   __git_setup_revision_arguments

   _arguments -S \
     $revision_arguments \
-    '*:object:__git_revisions' && ret=0
+    '*:object:->object' && ret=0
+
+  case $state in
+    (object)
+      compset -P '*:'
+      if [[ -n $IPREFIX ]]; then
+        __git_tree_files $IPREFIX[1,-2]
+      else
+        _alternative \
+          'revisions:revision:__git_revisions' \
+          'files:file:__git_files'
+      fi
+      ;;
+  esac
 }

 (( $+functions[_git-show-index] )) ||


-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author