From b16daf7009d9b49d3a1cc83b024a1b10409fc848 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 9 Jun 2009 22:48:05 +0200 Subject: help: Added -t option to only search a specific topic --- etc/functions/help | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'etc') 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 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)) { -- cgit v1.2.3