dotfiles/recipes/_path

31 lines
517 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 >/dev/null || echo $line >> $filename
}
function _profile {
[ -w ~/.bash_profile ] && __addline ~/.bash_profile $@
__addline ~/.profile "$@"
__addline ~/.zprofile "$@"
}
2018-02-22 14:56:10 +00:00
function _path_low {
PATH="$1:$PATH"
_profile "export PATH='$1'":'"$PATH"'
2018-02-22 14:56:10 +00:00
}
function _path_high {
PATH="$PATH:$1"
_profile 'export PATH="$PATH"':"'$1'"
2018-02-22 14:56:10 +00:00
}
function _path {
_path_low $@
}