From: martin f. krafft Date: Thu, 8 May 2008 10:45:29 +0000 (+0100) Subject: improve path manipulation X-Git-Url: https://git.madduck.net/etc/zsh.git/commitdiff_plain/1b92289b17509336e85613d96bfdef8827c3465c?ds=inline improve path manipulation --- diff --git a/.zsh/zprofile/00_path b/.zsh/zprofile/00_path index bac01d4..230e94f 100644 --- a/.zsh/zprofile/00_path +++ b/.zsh/zprofile/00_path @@ -8,18 +8,27 @@ # Source repository: http://git.madduck.net/v/etc/zsh.git # -for p in $HOME/bin $HOME/.bin; do - case "$PATH" in - "*:${p}:*"|"${p}:*"|"*:${p}") :;; - *) PATH="${p}:$PATH";; - esac -done +__prepend_dir_to_path() +{ + for dir; do + case "$PATH" in + "*:${dir}:*"|"${dir}:*"|"*:${dir}") :;; + *) test -d "$dir" && path=("$dir" $path);; + esac + done +} -for p in /usr/lib/surfraw; do - case "$PATH" in - "*:${p}:*"|"${p}:*"|"*:${p}") :;; - *) PATH="${PATH}:$p";; - esac -done +__append_dir_to_path() +{ + for dir; do + case "$PATH" in + "*:${dir}:*"|"${dir}:*"|"*:${dir}") :;; + *) test -d "$dir" && path+="$dir";; + esac + done +} + +__prepend_dir_to_path $BINDIR +__append_dir_to_path /usr/lib/surfraw # vim:ft=zsh