Skip to content

Instantly share code, notes, and snippets.

@zph
Created September 10, 2014 13:27
Show Gist options
  • Select an option

  • Save zph/47f7c7a4889c1a9be28f to your computer and use it in GitHub Desktop.

Select an option

Save zph/47f7c7a4889c1a9be28f to your computer and use it in GitHub Desktop.
Three commands for managing your $PATH
_remove_from_path(){
local item="$1"
cleansed_path=$(echo -n $PATH | tr ':' "\n" | grep -v "^${item}$" | grep -v '^$' | tr "\n" ':')
export PATH=$cleansed_path
}
_add_to_path(){
local item="$1"
export PATH=${item}:$PATH
}
_prepend_to_path(){
local item="$1"
_remove_from_path "$item"
_add_to_path "$item"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment