From 370726e0ccc14eab5f0736fc3f07efbad64d2943 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 24 Apr 2013 02:43:56 +0200 Subject: Move PATHS to .zshrc And use a new function to make it clean --- .zsh/functions/add-to-list | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .zsh/functions/add-to-list (limited to '.zsh/functions/add-to-list') 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 -- cgit v1.2.3-54-g00ecf