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

Re: run-help: Support for svn and git



Hi,

Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Of course at this point we ought to add something to the manual (in the
> contributions section, perhaps?) about the run-help function and its,
> um, helpers.

Is run-help really an alias, by default? At Debian it is the function
from Functions/Misc.

The first patch changes the text for the case the alias is not the
default and the second one explains the new behaviour.

--- contrib.yo+	2007-12-31 18:41:54.000000000 +0100
+++ contrib.yo	2007-12-31 18:54:23.000000000 +0100
@@ -31,10 +31,10 @@
 ifzman(zmanref(zshzle))\
 ifnzman(noderef(Zsh Line Editor))\
 ).  This invokes the tt(run-help) command with the command word from the
-current input line as its argument.  By default, tt(run-help) is an alias
-for the tt(man) command, so this often fails when the command word is a
-shell builtin or a user-defined function.  By redefining the tt(run-help)
-alias, one can improve the on-line help provided by the shell.
+current input line as its argument.  tt(run-help) can simply be an alias
+for the tt(man) command, but so this often fails when the command word is a
+shell builtin or a user-defined function.  By default, tt(run-help)
+is an more intelligent function found in tt(Functions/Misc).
 
 The tt(helpfiles) utility, found in the tt(Util) directory of the
 distribution, is a Perl program that can be used to process the zsh manual
@@ -61,23 +61,13 @@
 Next, to use the tt(run-help) function, you need to add lines something
 like the following to your tt(.zshrc) or equivalent startup file:
 
-example(unalias run-help
-autoload run-help
-HELPDIR=~/zsh_help)
+example(HELPDIR=~/zsh_help)
 
 vindex(HELPDIR)
 The tt(HELPDIR) parameter tells tt(run-help) where to look for the help
 files.  If your system already has a help file directory installed, set
 tt(HELPDIR) to the path of that directory instead.
 
-Note that in order for `tt(autoload run-help)' to work, the tt(run-help)
-file must be in one of the directories named in your tt(fpath) array (see
-ifzman(zmanref(zshparam))\
-ifnzman(noderef(Parameters Used By The Shell))\
-).  This should already be the case if you have a standard zsh
-installation; if it is not, copy tt(Functions/Misc/run-help) to an
-appropriate directory.
-
 subsect(Recompiling Functions)
 cindex(functions, recompiling)
 cindex(zrecompile utility)

diff -u contrib.yo contrib.yo
--- contrib.yo	2007-12-31 18:54:23.000000000 +0100
+++ contrib.yo	2007-12-31 19:18:01.000000000 +0100
@@ -68,6 +68,40 @@
 files.  If your system already has a help file directory installed, set
 tt(HELPDIR) to the path of that directory instead.
 
+If a command, alias or function tt(run-help-CMD) exists than tt(run-help)
+executes this to get help for the command tt(CMD) and passes to it all
+arguments of the command. This way you can define specialised functions
+for some commands. Here are some examples:
+
+example(run-help-svn()
+{
+    svn help ${${@:#-*}[1]} | ${=PAGER:-/usr/bin/pager}
+})
+
+example(run-help-git()
+{
+    if [ $# -eq 0 ]; then
+        man git
+    else
+        local al
+        if al=$(git config --get "alias.$1"); then
+            1=${al%% *}
+        fi
+        man git-$1
+    fi
+})
+
+example(run-help-ssh()
+{
+    local args
+    args=(${@:#-*})
+    if [ ${#args} -lt 2 ]; then
+        man ssh
+    else
+        run-help $args[2]
+    fi
+})
+
 subsect(Recompiling Functions)
 cindex(functions, recompiling)
 cindex(zrecompile utility)

Bye, Jörg.
-- 
“Perl—the only language that looks the same
 before and after RSA encryption.”           (Keith Bostic)



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