Skip to content

Instantly share code, notes, and snippets.

@oowekyala
Created January 14, 2024 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oowekyala/212295de486f57edb12e7f75ce2c3ef5 to your computer and use it in GitHub Desktop.
Save oowekyala/212295de486f57edb12e7f75ce2c3ef5 to your computer and use it in GitHub Desktop.
PATH manipulation functions, put into rc file
# 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