diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2008-05-17 22:42:16 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2008-05-17 22:42:16 +0000 |
commit | c894f695cc02f16af429c7506bb78354dcd9a1e3 (patch) | |
tree | 315daebee1a9ebc507790baf516863b0ff450f66 /Functions/Misc/add-zsh-hook | |
parent | adeceae8bfb6ed0a3fdea87cc4483c4d990f83fe (diff) | |
download | zsh-c894f695cc02f16af429c7506bb78354dcd9a1e3.tar.gz zsh-c894f695cc02f16af429c7506bb78354dcd9a1e3.tar.xz zsh-c894f695cc02f16af429c7506bb78354dcd9a1e3.zip |
25095: thorough modernization of prompt theme system
Diffstat (limited to 'Functions/Misc/add-zsh-hook')
-rw-r--r-- | Functions/Misc/add-zsh-hook | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Functions/Misc/add-zsh-hook b/Functions/Misc/add-zsh-hook index b11db5b5c..d349ac635 100644 --- a/Functions/Misc/add-zsh-hook +++ b/Functions/Misc/add-zsh-hook @@ -4,6 +4,9 @@ # # With -d, remove the function from the hook instead; delete the hook # variable if it is empty. +# +# -D behaves like -d, but pattern characters are active in the +# function name, so any matching function will be deleted from the hook. # # Without -d, the FUNCTION is marked for autoload; -U is passed down to # autoload if that is given. (This is harmless if the function is actually @@ -18,12 +21,16 @@ local opt local -a autoopts integer del -while getopts "d" opt; do +while getopts "dDU" opt; do case $opt in (d) del=1 ;; + (D) + del=2 + ;; + (U) autoopts+=(-$opt) ;; @@ -46,7 +53,11 @@ local fn="$2" if (( del )); then # delete, if hook is set if (( ${(P)+hook} )); then - set -A $hook ${(P)hook:#$fn} + if (( del == 2 )); then + set -A $hook ${(P)hook:#${~fn}} + else + set -A $hook ${(P)hook:#$fn} + fi # unset if no remaining entries --- this can give better # performance in some cases (( ${(P)#hook} )) || unset $hook |