Make zsh-quickstart-kit ZDOTDIR-aware and nounset-resilient #312
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR: Make zsh-quickstart-kit ZDOTDIR-aware and nounset-resilient
This change makes core zsh-quickstart-kit files work seamlessly when users set ZDOTDIR to a custom configuration directory, and hardens them against
setopt nounset(error on unset parameters).Summary of changes
Files modified:
~/...paths to zsh config files with${ZDOTDIR:-$HOME}/...${VAR-},${VAR:-default},(( ${+VAR} )))~/.zqs-zprof-enabled,~/.zqs-debug-mode,~/.zqs-settings-path,~/.zqs-settings~/.zshrc.pre-plugins.d,~/.zshrc.add-plugins.d,~/.zshrc.d,~/.zshrc.$(uname).d,~/.zshrc.work.d~/.zgen-setup,~/.zsh_functions,~/.zsh_aliases,~/.sh_aliases~/.zsh/completionscache path,~/.zsh-completions(.d)~/.macos_aliases(.d),~/.osx_aliases(.d)~/.zsh_history,~/.zsh-quickstart-last-update,~/.p10k.zsh[[ -z "$LSCOLORS" ]]->[[ -z ${LSCOLORS-} ]][[ -z "$SSH_CLIENT" ]]->[[ -z ${SSH_CLIENT-} ]][[ -z "$GENCOMPL_PY" ]]->[[ -z ${GENCOMPL_PY-} ]][[ -n "$ZSH_COMPLETION_HACK" ]]->[[ -n ${ZSH_COMPLETION_HACK-} ]][[ -z "$TREE_IGNORE" ]]->[[ -z ${TREE_IGNORE-} ]][[ -n "$GOPATH" ]]->[[ -n ${GOPATH-} ]][[ -n "$DESK_ENV" ]]->[[ -n ${DESK_ENV-} ]]load-shell-fragmentsnow guards$1with${1-}and properly quotes pathsZGEN_DIR=${ZGEN_DIR:-${ZDOTDIR:-$HOME}/.zgenom}${ZDOTDIR:-$HOME}for prompt change marker, additional-plugins, OMZ gating, plugin directories, and zgen init timestamps.zgen-local-plugins,.zsh-quickstart-local-plugins${ZDOTDIR:-$HOME}/.zsh/complete)need_updateif (( ${+EDITOR} )); then export VISUAL="$EDITOR"; fi${ZDOTDIR:-$HOME}/.zsh_aliases.localinstead of~/.zsh_aliases.local${ZDOTDIR:-$HOME}/.zsh_functions.localinstead of~/.zsh_functions.localBehavior when ZDOTDIR is unset remains identical because
${ZDOTDIR:-$HOME}falls back to$HOME.Rationale
$XDG_CONFIG_HOME/zsh)$HOMEwhen ZDOTDIR is unsetHow to test
Test matrix:
$HOME)Common setup:
.zshrcis a symlink to the kit’szsh/.zshrc(as recommended by zqs docs)A) ZDOTDIR set
ZDOTDIR="$HOME/dotfiles/dot-config/zsh" ZSH_FORCE_ZGEN_RESET=1 zsh -i -c exitZDOTDIR="$HOME/dotfiles/dot-config/zsh" zsh -i -c exitparameter not seterrors${ZDOTDIR}/.zsh_history${ZDOTDIR}/.zsh/cache.zgenom/init.zshcreated under${ZDOTDIR}/.zgenom/B) ZDOTDIR unset
$HOME:env -u ZDOTDIR ZSH_FORCE_ZGEN_RESET=1 zsh -i -c exitenv -u ZDOTDIR zsh -i -c exit$HOMEinstead of${ZDOTDIR}Smoke checks in both scenarios:
zqs update-plugins(via zgenom)zqs check-for-updates(last-update stamp is at${ZDOTDIR}/.zsh-quickstart-last-update)~/.zqs-zprof-enabledin the active ZDOTDIR and confirm zprof loads/suppressesSuggested branch name and commit message
fix/zdotdir-nounset-resilienceMake zsh-quickstart-kit ZDOTDIR-aware and nounset-resilientOpen the PR upstream
From the kit checkout directory (the repo that contains
zsh/.zshrc):git checkout -b fix/zdotdir-nounset-resiliencegit add zsh/.zshrc zsh/.zgen-setup zsh/.zsh_aliases zsh/.zsh_functionsgit commit -m "Make zsh-quickstart-kit ZDOTDIR-aware and nounset-resilient\n\n- Use \${ZDOTDIR:-$HOME} for config paths\n- Guard unset vars with \${VAR-}/\${VAR:-default}/(( \${+VAR} ))\n- Preserve behavior when ZDOTDIR unset"gh repo fork --remote --remote-name forkgit push -u fork fix/zdotdir-nounset-resiliencegh pr create --base main --head <your-user>:fix/zdotdir-nounset-resilience \ --title "Make zsh-quickstart-kit ZDOTDIR-aware and nounset-resilient" \ --body "See description and test plan in the PR. Maintains backward compatibility when ZDOTDIR is unset."Manual alternative:
https://github.com/unixorn/zsh-quickstart-kit/compare/main...<your-user>:fix/zdotdir-nounset-resilience?expand=1Notes
~/.ssh,~/.aws) intentionally left under$HOME.