fix: respect ZSH's $ZDOTDIR environment variable (#942)

ZSH reads its configuration by default relative to a path that's set via $ZDOTDIR. If $ZDOTDIR is not set, then the value of $HOME is used; this is the usual case. Source:  https://zsh.sourceforge.io/Intro/intro_3.html#IDX11

Also $HOME is save to use, because "The system shall initialize this variable at the time of login to be a pathname of the user's home directory". Source: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html

Lastly, the shell parameter expansion syntax is save to use generically: https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02

Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
This commit is contained in:
Dennis Trautwein 2023-12-09 18:52:09 +01:00 committed by GitHub
parent de6221942a
commit bdd7fe661f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,7 +184,7 @@ esac
# Use of single quotes around $() is intentional here
# shellcheck disable=SC2016
if ! grep -q "atuin init zsh" ~/.zshrc; then
printf '\neval "$(atuin init zsh)"\n' >> ~/.zshrc
printf '\neval "$(atuin init zsh)"\n' >> "${ZDOTDIR:-$HOME}/.zshrc"
fi
# Use of single quotes around $() is intentional here