dotfiles/recipes/_path

29 lines
668 B
Text
Raw Normal View History

2018-02-22 14:56:10 +00:00
#!/bin/bash
2018-02-27 05:15:14 +00:00
set -e
2018-02-22 14:56:10 +00:00
function __addline {
local filename=$1
shift
local line="$@"
grep "^$line\$" $filename || echo $line >> $filename
}
2018-02-22 14:56:10 +00:00
function _path_low {
PATH="$1:$PATH"
test -r ~/.bash_profile && __addline ~/.bash_profile "export PATH='$1'":'"$PATH"'
__addline ~/.profile "export PATH='$1'":'"$PATH"'
__addline ~/.zshenv "export PATH='$1'":'"$PATH"'
2018-02-22 14:56:10 +00:00
}
function _path_high {
PATH="$PATH:$1"
test -r ~/.bash_profile && __addline ~/.bash_profile 'export PATH="$PATH"':"'$PATH'"
__addline ~/.profile "export PATH='$1'":'"$PATH"'
__addline ~/.zshenv "export PATH='$1'":'"$PATH"'
2018-02-22 14:56:10 +00:00
}
function _path {
_path_low $@
}