Skip to content

Instantly share code, notes, and snippets.

@numpde
Last active November 9, 2017 04:00
Show Gist options
  • Save numpde/7e0bd69291369c980e0271d1e88798d4 to your computer and use it in GitHub Desktop.
Save numpde/7e0bd69291369c980e0271d1e88798d4 to your computer and use it in GitHub Desktop.
Write [addpath PATH "/some/path"] instead of [export PATH="/some/path:$PATH"]
#/bin/bash
# License-free
# Example: addpath PATH "/usr/bin"
addpath() {
varname=$1
export $1="$2:${!varname}"
}
export X="/fake/path0"
echo Before: $X
addpath X "/fake/path1"
echo After : $X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment