mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-02-22 05:13:10 +08:00
Fixing PATH when using brew plugin
This commit is contained in:
parent
0f17a02487
commit
edff7dea0a
28
plugins/brew/brew.load.fish
Normal file
28
plugins/brew/brew.load.fish
Normal file
@ -0,0 +1,28 @@
|
||||
function _path_index
|
||||
if test $PATH[$argv[1]] = $argv[2]
|
||||
echo 'Path index correct'
|
||||
end
|
||||
end
|
||||
|
||||
# Set /usr/local/bin before /usr/bin if defined on $PATH
|
||||
if contains /usr/local/bin $PATH
|
||||
if contains /usr/bin $PATH
|
||||
for i in (seq (count $PATH))
|
||||
if test (_path_index $i '/usr/bin')
|
||||
set -g bin_index $i
|
||||
else
|
||||
if test (_path_index $i '/usr/local/bin')
|
||||
set -g local_bin_index $i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if test $bin_index -lt $local_bin_index
|
||||
set PATH[$bin_index] /usr/local/bin
|
||||
set PATH[$local_bin_index] /usr/bin
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set -e bin_index
|
||||
set -e local_bin_index
|
Loading…
x
Reference in New Issue
Block a user