Skip to content

Instantly share code, notes, and snippets.

@jaantollander
Created August 10, 2021 04:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaantollander/9084d066ca4f854593c9afc4695796d8 to your computer and use it in GitHub Desktop.
Save jaantollander/9084d066ca4f854593c9afc4695796d8 to your computer and use it in GitHub Desktop.
Adding to PATH in idempotent way, that is, without repetition.
# https://unix.stackexchange.com/a/124447
add_to_path() {
case ":${PATH:=$1}:" in *:"$1":*) ;; *) PATH="$1:$PATH" ;; esac;
}
# Example
add_to_path $HOME/bin/julia-1.6.1/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment