Use safer append to hook function arrays (#8406)

Use add-zsh-hook to add functions to hooks. That way they won't be added again
when doing `source ~/.zshrc` multiple times.

Co-authored-by: Marc Cornellà <marc.cornella@live.com>
This commit is contained in:
Jacob Tomaw 2019-11-19 12:47:12 -05:00 committed by Marc Cornellà
commit 1ba0af650a
12 changed files with 29 additions and 23 deletions

View file

@ -28,7 +28,8 @@ prompt_setup_pygmalion(){
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
precmd_functions+=(prompt_pygmalion_precmd)
autoload -U add-zsh-hook
add-zsh-hook precmd prompt_pygmalion_precmd
}
prompt_pygmalion_precmd(){
@ -46,5 +47,3 @@ prompt_pygmalion_precmd(){
}
prompt_setup_pygmalion