diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2012-07-22 21:40:10 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2012-07-22 21:40:10 +0200 |
commit | 5c7ac461932c17df91374e6c2740ad22c95481af (patch) | |
tree | 85d21004331d9d1bfca266d111000acd7fa1725a /Functions/Misc/add-zsh-hook | |
parent | 3988419a8dc4a74e491df584804a77a2f8be88cd (diff) | |
parent | e27142d45686cacc6ed155e5045b97dd6243d44c (diff) | |
download | zsh-5c7ac461932c17df91374e6c2740ad22c95481af.tar.gz zsh-5c7ac461932c17df91374e6c2740ad22c95481af.zip |
New upstream release
Diffstat (limited to 'Functions/Misc/add-zsh-hook')
-rw-r--r-- | Functions/Misc/add-zsh-hook | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Functions/Misc/add-zsh-hook b/Functions/Misc/add-zsh-hook index c49688643..ee37d674d 100644 --- a/Functions/Misc/add-zsh-hook +++ b/Functions/Misc/add-zsh-hook @@ -19,12 +19,13 @@ hooktypes=( chpwd precmd preexec periodic zshaddhistory zshexit zsh_directory_name ) +local usage="Usage: $0 hook function\nValid hooks are:\n $hooktypes" local opt local -a autoopts -integer del +integer del list help -while getopts "dDUzk" opt; do +while getopts "dDhLUzk" opt; do case $opt in (d) del=1 @@ -34,6 +35,14 @@ while getopts "dDUzk" opt; do del=2 ;; + (h) + help=1 + ;; + + (L) + list=1 + ;; + ([Uzk]) autoopts+=(-$opt) ;; @@ -45,9 +54,12 @@ while getopts "dDUzk" opt; do done shift $(( OPTIND - 1 )) -if (( $# != 2 || ${hooktypes[(I)$1]} == 0 )); then - print "Usage: $0 hook function\nValid hooks are:\n $hooktypes" - return 1 +if (( list )); then + typeset -mp "(${1:-${(@j:|:)hooktypes}})_functions" + return $? +elif (( help || $# != 2 || ${hooktypes[(I)$1]} == 0 )); then + print -u$(( 2 - help )) $usage + return $(( 1 - help )) fi local hook="${1}_functions" |