* run-help git subcommand
@ 2007-11-11 12:41 Jörg Sommer
2007-11-13 0:51 ` run-help git subcommand [PATCH] Jörg Sommer
0 siblings, 1 reply; 2+ messages in thread
From: Jörg Sommer @ 2007-11-11 12:41 UTC (permalink / raw)
To: zsh-workers
Hi,
is it possible to lookup the help for “git subcommand” as “run-help
git-subcommand”. My idea was to access the buffer stack in run-help to
get the subcommand but this doesn't work.
[[ $1 == "." ]] && 1="dot"
[[ $1 == ":" ]] && 1="colon"
if [[ $1 == git ]]; then
local full_cmd
getln full_cmd
print -z "$full_cmd"
i=0
while [[ $i -lt $#full_cmd ]]; do
case $full_cmd[$i] in
-*|git) ;;
*)
1=git-"$full_cmd[$i]"
break
;;
esac
((++i))
done
fi
How can I make ESC-H runs git-subcommand for git subcommand?
Thanks, Jörg.
--
Ich halte ihn zwar für einen Schurken und das was er sagt für
falsch – aber ich bin bereit mein Leben dafür einzusetzen, daß
er seine Meinung sagen kann. (Voletair)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: run-help git subcommand [PATCH]
2007-11-11 12:41 run-help git subcommand Jörg Sommer
@ 2007-11-13 0:51 ` Jörg Sommer
0 siblings, 0 replies; 2+ messages in thread
From: Jörg Sommer @ 2007-11-13 0:51 UTC (permalink / raw)
To: zsh-workers
Hi,
Jörg Sommer <joerg@alea.gnuu.de> 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-11-13 1:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-11 12:41 run-help git subcommand Jörg Sommer
2007-11-13 0:51 ` run-help git subcommand [PATCH] Jörg Sommer
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).