From 66742c60451a1741688245d682471611f33372a5 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Mon, 31 Dec 2007 22:13:46 +0000 Subject: 24332, 24333: Improvements to run-help suggested by J.Sommer. --- ChangeLog | 11 +++++++++++ Functions/Misc/.distfiles | 25 ++++++++++++++++++++++--- Functions/Misc/run-help | 19 ++++++++++++++++++- Functions/Misc/run-help-git | 10 ++++++++++ Functions/Misc/run-help-svk | 1 + Functions/Misc/run-help-svn | 1 + 6 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 Functions/Misc/run-help-git create mode 100644 Functions/Misc/run-help-svk create mode 100644 Functions/Misc/run-help-svn diff --git a/ChangeLog b/ChangeLog index e2aff2e65..4313a3862 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-12-31 Barton E. Schaefer + + * J.Sommer: 24333: Functions/Misc/.distfiles, + Functions/Misc/run-help-git, Functions/Misc/run-help-svk, + Functions/Misc/run-help-svn: run-help helpers. + + * 24332: Functions/Misc/run-help: use only the path tail of $1 + when calling "man" et al. Look for a helper function named + run-help-$1 to provide specific help for the command, before + falling back on "man". + 2007-12-31 Clint Adams * 24330: Completion/X/_xpdf: add some missing options from xpdf diff --git a/Functions/Misc/.distfiles b/Functions/Misc/.distfiles index edfe128ac..2d515035f 100644 --- a/Functions/Misc/.distfiles +++ b/Functions/Misc/.distfiles @@ -1,8 +1,27 @@ DISTFILES_SRC=' .distfiles add-zsh-hook -allopt getjobs mere relative zcalc zmv zargs -checkmail harden nslookup run-help zed zrecompile -colors is-at-least promptnl tetris zkbd zstyle+ +allopt +checkmail +colors +getjobs +harden +is-at-least +mere +nslookup +promptnl +relative +run-help +run-help-git +run-help-svk +run-help-svn +tetris +zargs +zcalc +zed +zkbd zmathfuncdef +zmv +zrecompile +zstyle+ ' diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help index ec0334118..cfa67f652 100644 --- a/Functions/Misc/run-help +++ b/Functions/Misc/run-help @@ -85,7 +85,24 @@ do man zshmisc ;; (*) - ((! didman++)) && man $@ + if ((! didman++)) + then + if whence "run-help-$1:t" >/dev/null + then + local cmd_args + builtin getln cmd_args + builtin print -z "$cmd_args" + cmd_args=( ${(z)cmd_args} ) + # Discard environment assignments, etc. + while [[ $cmd_args[1] != $1 ]] + do + shift cmd_args + done + eval "run-help-$1:t ${(@)cmd_args[2,-1]}" + else + man $@:t + fi + fi ;; esac if ((i < $#places && ! didman)) diff --git a/Functions/Misc/run-help-git b/Functions/Misc/run-help-git new file mode 100644 index 000000000..51c6e250c --- /dev/null +++ b/Functions/Misc/run-help-git @@ -0,0 +1,10 @@ +#!/bin/zsh +if [ $# -eq 0 ]; then + man git +else + local al + if al=$(git config --get "alias.$1"); then + 1=${al%% *} + fi + man git-$1 +fi diff --git a/Functions/Misc/run-help-svk b/Functions/Misc/run-help-svk new file mode 100644 index 000000000..92438a53f --- /dev/null +++ b/Functions/Misc/run-help-svk @@ -0,0 +1 @@ +svk help ${${@:#-*}[1]} | ${=PAGER:-more} diff --git a/Functions/Misc/run-help-svn b/Functions/Misc/run-help-svn new file mode 100644 index 000000000..5d1068588 --- /dev/null +++ b/Functions/Misc/run-help-svn @@ -0,0 +1 @@ +svn help ${${@:#-*}[1]} | ${=PAGER:-more} -- cgit 1.4.1