From 1b92289b17509336e85613d96bfdef8827c3465c Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Thu, 8 May 2008 11:45:29 +0100 Subject: [PATCH] improve path manipulation --- .zsh/zprofile/00_path | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) 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 -- 2.39.5