Skip to content

Instantly share code, notes, and snippets.

@lee-dohm
Last active December 21, 2015 16:59
Show Gist options
  • Save lee-dohm/6337324 to your computer and use it in GitHub Desktop.
Save lee-dohm/6337324 to your computer and use it in GitHub Desktop.
Code for article 'Shells and Scripting'
set --local bin_index (contains --index /usr/bin $PATH)
set --local local_bin_index (contains --index /usr/local/bin $PATH)
if test $local_bin_index -gt $bin_index
set --erase $PATH[$local_bin_index]
set --local local_path ''
if test (math $bin_index - 1) -gt 0
set local_path $PATH[1..(math $bin_index - 1)]
end
set local_path $local_path /usr/local/bin
set local_path $local_path $PATH[$bin_index..-1]
set --global --export PATH $local_path
end
path = ENV['PATH'].split(/:/)
bin_index = path.find_index('/usr/bin')
local_bin_index = path.find_index('/usr/local/bin')
if local_bin_index > bin_index
path.delete_at(local_bin_index)
path.insert(bin_index, '/usr/local/bin')
ENV['PATH'] = path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment