diff options
Diffstat (limited to '.zsh/functions')
-rw-r--r-- | .zsh/functions/Makefile | 2 | ||||
-rw-r--r-- | .zsh/functions/add-to-list | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/.zsh/functions/Makefile b/.zsh/functions/Makefile index d410977..617d883 100644 --- a/.zsh/functions/Makefile +++ b/.zsh/functions/Makefile @@ -2,6 +2,6 @@ SUBDIR=functions objects=chpwd_show_todo chpwd_update_git_vars env get_cnt line \ precmd_maybe_festival precmd_update_git_vars precmd_update_updates \ preexec_update_vars prompt prompt_git_info rprompt \ - update_current_git_vars welcome venv + update_current_git_vars welcome venv add-to-list include ../../dotfiles.mk diff --git a/.zsh/functions/add-to-list b/.zsh/functions/add-to-list new file mode 100644 index 0000000..18720e0 --- /dev/null +++ b/.zsh/functions/add-to-list @@ -0,0 +1,10 @@ +# -*- mode: sh; -*- +if [[ ! "${(P)${1}}" =~ (^|:)"$2"(:|$) ]]; then + if [ -n "$3" ]; then + # Append + typeset -g $1="${(P)${1}}:$2" + else + # Prepend + typeset -g $1="$2:${(P)${1}}" + fi +fi |