aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/config.fish
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-08-25 13:25:24 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-08-25 13:27:52 -0700
commitdead45fa67773324ec136acc37184e40af3cfe9f (patch)
tree62ad90c3ec94cdf8c8e81da11a54932155da152d /share/config.fish
parenta8af97489549ef737b1518888545c9fedcf380ef (diff)
Rearrange the PATH to respect the order defined in /etc/paths (#927) and
to prepend it to $PATH instead of appending it (#950)
Diffstat (limited to 'share/config.fish')
-rw-r--r--share/config.fish55
1 files changed, 29 insertions, 26 deletions
diff --git a/share/config.fish b/share/config.fish
index 2c1f8b52..e7ca703f 100644
--- a/share/config.fish
+++ b/share/config.fish
@@ -57,41 +57,44 @@ if test -d /usr/xpg4/bin
end
end
-# Add a handler for when fish_user_path changes, so we can apply the same changes to PATH
-# Invoke it immediately to apply the current value of fish_user_path
-function __fish_reconstruct_path -d "Update PATH when fish_user_paths changes" --on-variable fish_user_paths
- set -l local_path $PATH
- set -l x
- for x in $__fish_added_user_paths
- if set -l idx (contains --index $x $local_path)
- set -e local_path[$idx]
- end
- end
-
- set -e __fish_added_user_paths
- for x in $fish_user_paths[-1..1]
- if not contains $x $local_path
- set local_path $x $local_path
- set -g __fish_added_user_paths $__fish_added_user_paths $x
- end
- end
- set -xg PATH $local_path
-end
-__fish_reconstruct_path
-
# OS X-ism: Load the path files out of /etc/paths and /etc/paths.d/*
+set -g __fish_tmp_path $PATH
function __fish_load_path_helper_paths
while read -l new_path_comp
- if not contains $new_path_comp $PATH
- set PATH $PATH $new_path_comp
- end
+ # We want to rearrange the path to reflect this order. Delete that path component if it exists and then prepend it.
+ set -l where (contains -i $new_path_comp $__fish_tmp_path)
+ and set -e __fish_tmp_path[$where]
+ set __fish_tmp_path $new_path_comp $__fish_tmp_path
end
end
-if test -r /etc/paths ; __fish_load_path_helper_paths < /etc/paths ; end
+test -r /etc/paths ; and __fish_load_path_helper_paths < /etc/paths
for pathfile in /etc/paths.d/* ; __fish_load_path_helper_paths < $pathfile ; end
+set -xg PATH $__fish_tmp_path
+set -e __fish_tmp_path
functions -e __fish_load_path_helper_paths
+# Add a handler for when fish_user_path changes, so we can apply the same changes to PATH
+# Invoke it immediately to apply the current value of fish_user_path
+function __fish_reconstruct_path -d "Update PATH when fish_user_paths changes" --on-variable fish_user_paths
+ set -l local_path $PATH
+ set -l x
+ for x in $__fish_added_user_paths
+ set -l idx (contains --index $x $local_path)
+ and set -e local_path[$idx]
+ end
+
+ set -e __fish_added_user_paths
+ for x in $fish_user_paths[-1..1]
+ if not contains $x $local_path
+ set local_path $x $local_path
+ set -g __fish_added_user_paths $__fish_added_user_paths $x
+ end
+ end
+ set -xg PATH $local_path
+end
+__fish_reconstruct_path
+
#
# Launch debugger on SIGTRAP
#