diff options
author | Tom Willemse | 2013-08-13 20:53:57 +0200 |
---|---|---|
committer | Tom Willemse | 2013-08-13 20:53:57 +0200 |
commit | 2a133f4a39b120cf89755a6222760e1d6c4a45ce (patch) | |
tree | aa5d3e6933072005da11fea6e21b9f4352a2f629 /.zsh/functions/add-to-list | |
download | zsh-2a133f4a39b120cf89755a6222760e1d6c4a45ce.tar.gz zsh-2a133f4a39b120cf89755a6222760e1d6c4a45ce.zip |
Initial commit of my ZSH configuration in vcsh
Diffstat (limited to '.zsh/functions/add-to-list')
-rw-r--r-- | .zsh/functions/add-to-list | 10 |
1 files changed, 10 insertions, 0 deletions
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 |