summaryrefslogtreecommitdiffstats
path: root/.zsh/functions/add-to-list
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-04-24 02:43:56 +0200
committerGravatar Tom Willemse2013-04-24 02:43:56 +0200
commit370726e0ccc14eab5f0736fc3f07efbad64d2943 (patch)
tree581ecac3603e1017a28dce9ce090872d81abb6f0 /.zsh/functions/add-to-list
parentd9323f0c017dddccfc0a107690736477527ea33f (diff)
downloaddotfiles-370726e0ccc14eab5f0736fc3f07efbad64d2943.tar.gz
dotfiles-370726e0ccc14eab5f0736fc3f07efbad64d2943.zip
Move PATHS to .zshrc
And use a new function to make it clean
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