Skip to content

Instantly share code, notes, and snippets.

@andrewcrook
Forked from jaantollander/.bashrc
Created January 7, 2023 15:25
Show Gist options
  • Save andrewcrook/6e60d1c4799c9dab9af25d4f12b1e3da to your computer and use it in GitHub Desktop.
Save andrewcrook/6e60d1c4799c9dab9af25d4f12b1e3da 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