diff options
author | 2014-07-01 22:52:29 +0200 | |
---|---|---|
committer | 2014-07-01 22:52:29 +0200 | |
commit | d494d318ceedcfc18c81440eb29bd681084ff65c (patch) | |
tree | 3b889379ed2115d9def65e21c82463e4f6b7f746 /zsh/functions/add-to-list | |
parent | ff1b2cb7624d6d65f3488c03918e3c18cccfd21d (diff) | |
download | dotfiles-d494d318ceedcfc18c81440eb29bd681084ff65c.tar.gz dotfiles-d494d318ceedcfc18c81440eb29bd681084ff65c.zip |
Rename .zsh
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 |