]> git.donarmstrong.com Git - zsh.git/commitdiff
improve path manipulation
authormartin f. krafft <madduck@madduck.net>
Thu, 8 May 2008 10:45:29 +0000 (11:45 +0100)
committermartin f. krafft <madduck@madduck.net>
Thu, 8 May 2008 11:01:29 +0000 (12:01 +0100)
.zsh/zprofile/00_path

index bac01d48efab416c56b7cd4b4bdf8105ce608d54..230e94f14aa22f1c71a8d2a40e726644718f596c 100644 (file)
@@ -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