Use ZDOTDIR env variable for path to .zshrc

.zshrc can be found at "~/.zshrc", when ZDOTDIR is not set.
If ZDOTDIR is set, .zshrc is in "${ZDOTDIR}/.zshrc".
Using parameter expansion, the hardcoded path can be replaced with
"${ZDOTDIR:-$HOME}/.zshrc". That way, it'll use the value in
ZDOTDIR when set and the value in HOME when not.
This thus mirrors the usage of ZDOTDIR in zsh and makes the code
more fexible.
This commit is contained in:
Martin Rey
2020-03-09 22:25:17 +01:00
parent 8f5693f345
commit 1a7d86fdbc
3 changed files with 29 additions and 12 deletions

View File

@@ -7,9 +7,12 @@ if [[ $OSTYPE == "Darwin" ]]; then
sed="sed -i ''"
fi
for rc in bashrc zshrc; do
if [ -f "$HOME/.$rc" ]; then
$sed '/scm_breeze/d' "$HOME/.$rc" &&
printf "Removed SCM Breeze from %s\n" "$HOME/.$rc"
fi
done
if [ -f "$HOME/.bashrc" ]; then
$sed '/scm_breeze/d' "$HOME/.bashrc" &&
printf "Removed SCM Breeze from '%s'\n" "$HOME/.bashrc"
fi
if [ -f "${ZDOTDIR:-$HOME}/.zshrc" ]; then
$sed '/scm_breeze/d' "${ZDOTDIR:-$HOME}/.zshrc" &&
printf "Removed SCM Breeze from '%s'\n" "${ZDOTDIR:-$HOME}/.zshrc"
fi