Skip to content

Instantly share code, notes, and snippets.

@o11c
Created May 22, 2019 20:24
Show Gist options
  • Save o11c/03a4b321220395b97dadc3f1ca740db3 to your computer and use it in GitHub Desktop.
Save o11c/03a4b321220395b97dadc3f1ca740db3 to your computer and use it in GitHub Desktop.
# Significant care is taken to be sh-compatible; if bash or zsh could be
# required, it could be made simpler or more generic.
# Known source'rs:
# ~/.profile
# ~/.zshrc
# ~/.xprofile
# ~/.xsessionrc
# ~/.bashrc
# ~/.config/plasma-workspace/env/*.sh
has_PATH () {
local tmp=":$PATH:"
[ "${tmp}" != "${tmp#*:$1:}" ]
}
prepend_PATH () {
has_PATH "$1" || PATH="$1:$PATH"
}
append_PATH () {
has_PATH "$1" || PATH="$PATH:$1"
}
prepend_PATH /usr/local/bin
prepend_PATH ~/.local/bin
prepend_PATH ~/bin
prepend_PATH /usr/lib/ccache
append_PATH /usr/sbin
append_PATH /sbin
append_PATH /usr/local/games
append_PATH /usr/games
export PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment