mirror of
https://github.com/correl/dotfiles.git
synced 2024-11-16 03:00:08 +00:00
[provisioning] Make path additions idempotent
This commit is contained in:
parent
4c219d9db2
commit
0bd050086c
1 changed files with 14 additions and 4 deletions
|
@ -1,16 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
|
function __addline {
|
||||||
|
local filename=$1
|
||||||
|
shift
|
||||||
|
local line="$@"
|
||||||
|
|
||||||
|
grep "^$line\$" $filename || echo $line >> $filename
|
||||||
|
}
|
||||||
|
|
||||||
function _path_low {
|
function _path_low {
|
||||||
PATH="$1:$PATH"
|
PATH="$1:$PATH"
|
||||||
test -r ~/.bash_profile && echo "export PATH='$1'":'"$PATH"' >>~/.bash_profile
|
test -r ~/.bash_profile && __addline ~/.bash_profile "export PATH='$1'":'"$PATH"'
|
||||||
echo "export PATH='$1'":'"$PATH"' >>~/.profile
|
__addline ~/.profile "export PATH='$1'":'"$PATH"'
|
||||||
|
__addline ~/.zshenv "export PATH='$1'":'"$PATH"'
|
||||||
}
|
}
|
||||||
|
|
||||||
function _path_high {
|
function _path_high {
|
||||||
PATH="$PATH:$1"
|
PATH="$PATH:$1"
|
||||||
test -r ~/.bash_profile && echo 'export PATH="$PATH"':"'$PATH'" >>~/.bash_profile
|
test -r ~/.bash_profile && __addline ~/.bash_profile 'export PATH="$PATH"':"'$PATH'"
|
||||||
echo "export PATH='$1'":'"$PATH"' >>~/.profile
|
__addline ~/.profile "export PATH='$1'":'"$PATH"'
|
||||||
|
__addline ~/.zshenv "export PATH='$1'":'"$PATH"'
|
||||||
}
|
}
|
||||||
|
|
||||||
function _path {
|
function _path {
|
||||||
|
|
Loading…
Reference in a new issue