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

Re: run-help git subcommand [PATCH]



Hi,

Jörg Sommer <joerg@xxxxxxxxxxxx> wrote:
> is it possible to lookup the help for “git subcommand” as “run-help
> git-subcommand”.

Yes, it is and I expanded it for svn/svk. Here is my patch for run-help:

% diff -u /usr/share/zsh-beta/4.3.4-dev-1/functions/Misc/run-help bin/run-help
--- /usr/share/zsh-beta/4.3.4-dev-1/functions/Misc/run-help	2007-10-31 04:31:11.000000000 +0100
+++ bin/run-help	2007-11-13 01:47:30.000000000 +0100
@@ -12,8 +12,31 @@
 
 : ${HELPDIR:=/usr/share/zsh-beta/help}
 
-[[ $1 == "." ]] && 1="dot"
-[[ $1 == ":" ]] && 1="colon"
+local subcmd
+subcmd=
+
+case $1 in
+  (.) 1=dot;;
+  (:) 1=colon;;
+  (git|sv[kn])
+    local full_cmd
+    builtin getln full_cmd
+    builtin print -z "$full_cmd"
+    local i
+    for i in ${(z)full_cmd#*$1 }; do      # remove VARIABLE=... $1
+        case "$i" in
+          (-*) ;;
+          (*)
+            case $1 in
+              (git) 1="git-$i";;
+              (sv[kn]) subcmd=$i;;
+            esac
+            break
+            ;;
+        esac
+    done
+    ;;
+esac
 
 if [[ $# == 0 || $1 == "-l" ]]
 then
@@ -85,7 +109,11 @@
 	man zsh-betamisc
 	;;
     (*)
-	((! didman++)) && man $@
+        if [[ -n "${subcmd:-}" ]]; then
+            ((! didman++)) && $1 help $subcmd | ${=PAGER:-/usr/bin/pager}
+        else
+	    ((! didman++)) && man $@
+        fi
 	;;
     esac
     if ((i < $#places && ! didman))

zsh is really cool!

Bye, Jörg.
-- 
Die am Lautesten reden, haben stets am wenigsten zu sagen.



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