Use special function for appending to precmd_functions

This way there appear no duplicates.
This commit is contained in:
ZyX 2015-02-23 15:59:21 +03:00
parent ca6797055a
commit 76f73687cf
1 changed files with 9 additions and 8 deletions

View File

@ -12,6 +12,12 @@ _powerline_columns_fallback() {
return 0 return 0
} }
_powerline_append_precmd_function() {
if test -z "${precmd_functions[(re)$1]}" ; then
precmd_functions+=( $1 )
fi
}
integer _POWERLINE_JOBNUM integer _POWERLINE_JOBNUM
_powerline_init_tmux_support() { _powerline_init_tmux_support() {
@ -86,7 +92,7 @@ _powerline_init_modes_support() {
_POWERLINE_DEFAULT_MODE="$_POWERLINE_MODE" _POWERLINE_DEFAULT_MODE="$_POWERLINE_MODE"
fi fi
precmd_functions+=( _powerline_set_main_keymap_name ) _powerline_append_precmd_function _powerline_set_main_keymap_name
} }
_powerline_set_jobnum() { _powerline_set_jobnum() {
@ -110,17 +116,12 @@ _powerline_update_counter() {
_powerline_setup_prompt() { _powerline_setup_prompt() {
emulate -L zsh emulate -L zsh
for f in "${precmd_functions[@]}"; do _powerline_append_precmd_function _powerline_set_jobnum
if [[ "$f" = '_powerline_set_jobnum' ]]; then
return
fi
done
precmd_functions+=( _powerline_set_jobnum )
VIRTUAL_ENV_DISABLE_PROMPT=1 VIRTUAL_ENV_DISABLE_PROMPT=1
if test -z "${POWERLINE_NO_ZSH_ZPYTHON}" && { zmodload libzpython || zmodload zsh/zpython } &>/dev/null ; then if test -z "${POWERLINE_NO_ZSH_ZPYTHON}" && { zmodload libzpython || zmodload zsh/zpython } &>/dev/null ; then
precmd_functions+=( _powerline_update_counter ) _powerline_append_precmd_function _powerline_update_counter
zpython 'from powerline.bindings.zsh import setup as _powerline_setup' zpython 'from powerline.bindings.zsh import setup as _powerline_setup'
zpython '_powerline_setup(globals())' zpython '_powerline_setup(globals())'
zpython 'del _powerline_setup' zpython 'del _powerline_setup'