summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-06-09 22:48:05 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2009-06-09 22:48:05 +0200
commitb16daf7009d9b49d3a1cc83b024a1b10409fc848 (patch)
treecdb4272c7291bf696ffec0edc808d6b5550d30cb /etc
parentbe702a7fb4d605579bb634ec8f5a36d14b5f9c73 (diff)
help: Added -t option to only search a specific topic
Diffstat (limited to 'etc')
-rwxr-xr-xetc/functions/help18
1 files changed, 11 insertions, 7 deletions
diff --git a/etc/functions/help b/etc/functions/help
index a3712f0..aa0c269 100755
--- a/etc/functions/help
+++ b/etc/functions/help
@@ -2,14 +2,15 @@
## wrapper around man, finfo, etc
## Usage: help <topic>
typeset -a methods
-typeset method
+typeset method topic
typeset -i found check_only all
-methods=(man function builtin apt)
+methods=(man zshfunction zshbuiltin apt)
while [[ $1 == -* ]] {
case $1 in
- -c|--check-only) check_only=1 ;;
-a|--all) all=1 ;;
+ -c|--check-only) check_only=1 ;;
+ -t|--topic) topic=$2; shift ;;
-|--) shift; break ;;
*) echo "unknown option: $1" ;;
esac
@@ -17,15 +18,15 @@ while [[ $1 == -* ]] {
}
function help_check_man { man -w $1 &> /dev/null }
-function help_check_function { whichf $1 &> /dev/null }
-function help_check_builtin { (( ${+builtins[$1]} )) }
+function help_check_zshfunction { whichf $1 &> /dev/null }
+function help_check_zshbuiltin { (( ${+builtins[$1]} )) }
function help_check_apt {
[[ $commands[$1] != ${HOME}* ]] && check_com -c $1 && check_com -c apt-file
}
function help_show_man { man $1 }
-function help_show_function { finfo $1 }
-function help_show_builtin { man zshbuiltins | less -p " $1" }
+function help_show_zshfunction { finfo $1 }
+function help_show_zshbuiltin { man zshbuiltins | less -p " $1" }
function help_show_apt {
apt-cache show ${(s/:/)$(apt-file search -F $commands[$1])[1]}
}
@@ -36,6 +37,9 @@ if [[ -z $1 ]] {
}
for method in $methods; {
+ if [[ -n $topic && $method != $topic ]] {
+ continue
+ }
if help_check_$method $1; then
((found++))
if ((check_only)) {