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
|
|
|
|
2018-02-24 01:13:11 +00:00
|
|
|
function __addline {
|
|
|
|
local filename=$1
|
|
|
|
shift
|
|
|
|
local line="$@"
|
|
|
|
|
2018-02-28 06:25:48 +00:00
|
|
|
grep "^$line\$" $filename >/dev/null || echo $line >> $filename
|
|
|
|
}
|
|
|
|
|
|
|
|
function _profile {
|
|
|
|
[ -w ~/.bash_profile ] && __addline ~/.bash_profile $@
|
|
|
|
__addline ~/.profile "$@"
|
|
|
|
__addline ~/.zshenv "$@"
|
2018-02-24 01:13:11 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 14:56:10 +00:00
|
|
|
function _path_low {
|
|
|
|
PATH="$1:$PATH"
|
2018-02-28 06:25:48 +00:00
|
|
|
_profile "export PATH='$1'":'"$PATH"'
|
2018-02-22 14:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function _path_high {
|
|
|
|
PATH="$PATH:$1"
|
2018-02-28 06:25:48 +00:00
|
|
|
_profile 'export PATH="$PATH"':"'$1'"
|
2018-02-22 14:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function _path {
|
|
|
|
_path_low $@
|
|
|
|
}
|