From a7e11bc9f83c6f69ae2f96fb8a35cd6ca8ea186c Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 6 May 2008 21:40:58 +0100 Subject: [PATCH 1/1] use a loop to define functions --- .zsh/zshrc/99_hook_functions | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.zsh/zshrc/99_hook_functions b/.zsh/zshrc/99_hook_functions index a934d04..34abb0e 100644 --- a/.zsh/zshrc/99_hook_functions +++ b/.zsh/zshrc/99_hook_functions @@ -10,10 +10,13 @@ autoload -U is-at-least if ! is-at-least 4.3.6; then - precmd() { for fn ($precmd_functions) $fn "$@" } - preexec() { for fn ($preexec_functions) $fn "$@" } - chpwd() { for fn ($chpwd_functions) $fn "$@" } - periodic() { for fn ($periodic_functions) $fn "$@" } + for i in precmd preexec chpwd periodic; do + if [ -n "$functions[$i]" ]; then + warn "$i function already defined" + continue + fi + eval "${i}() { for fn (\$${i}_functions) \$fn \"\$@\" }" + done fi # vim:ft=zsh -- 2.39.5