summaryrefslogtreecommitdiffstats
path: root/.zsh/functions/add-to-list
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-05-15 17:35:51 +0200
committerGravatar Tom Willemse2013-05-15 17:35:51 +0200
commit6c2db7df0e40962537ce74d6f6213fac1782bd1b (patch)
tree57483bb4d37c243619d71123260711100afb1a93 /.zsh/functions/add-to-list
parent8ae90ffbd18d4312806e11cdda99e3dadcc9bf57 (diff)
downloaddotfiles-6c2db7df0e40962537ce74d6f6213fac1782bd1b.tar.gz
dotfiles-6c2db7df0e40962537ce74d6f6213fac1782bd1b.zip
Update dotfilesphoenix
Diffstat (limited to '.zsh/functions/add-to-list')
-rw-r--r--.zsh/functions/add-to-list10
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