Created
January 14, 2024 16:41
-
-
Save oowekyala/212295de486f57edb12e7f75ce2c3ef5 to your computer and use it in GitHub Desktop.
PATH manipulation functions, put into rc file
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
# Prepend a segment to the path (takes priority). | |
prepend_PATH() { | |
export PATH="$1:$PATH" | |
} | |
# Append something to your PATH (current PATH takes priority). | |
append_PATH() { | |
export PATH="$PATH:$1" | |
} | |
# Delete some part of the path based on a search string. | |
# https://unix.stackexchange.com/questions/108873/removing-a-directory-from-path | |
delete_from_PATH() { | |
local search="$1" | |
export PATH=`echo $PATH | tr ":" "\n" | grep -v "$search" | tr "\n" ":"` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment