Created
September 10, 2014 13:27
-
-
Save zph/47f7c7a4889c1a9be28f to your computer and use it in GitHub Desktop.
Three commands for managing your $PATH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _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