From ab472190971610fbea9f09d65bdb74619637583f Mon Sep 17 00:00:00 2001 From: bchanot Date: Wed, 28 Oct 2026 18:15:11 +0100 Subject: [PATCH] fix(install): identity read from the running shell's rc first resolve_identity always read ~/.bashrc before ~/.zshrc, so a stale bashrc USER shadowed the zsh one. Order now follows $SHELL. --- install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 715e67f..c5a7928 100755 --- a/install.sh +++ b/install.sh @@ -628,13 +628,17 @@ render_identity_template() { } # One identity value (USER or EMAIL, $1) for git commits, vim headers and the rc -# exports. Never stored in the repo. An export already in ~/.bashrc or ~/.zshrc -# wins silently (a re-run never asks twice), else IDENTITY_ from the +# exports. Never stored in the repo. An export already in the rc of the running +# shell ($SHELL, else the other rc) wins silently (a re-run never asks twice; +# the env is not read: a fresh machine's $USER is the login name, which would +# skip the prompt), else IDENTITY_ from the # environment, else a prompt ($2 label, $3 default) when a terminal is attached, # else the default. Prints the value. resolve_identity() { local var="$1" label="$2" default="$3" value="" rc envvar="IDENTITY_$1" - for rc in "$HOME/.bashrc" "$HOME/.zshrc"; do + local rcs=("$HOME/.bashrc" "$HOME/.zshrc") + [ "$(basename "${SHELL:-}")" = zsh ] && rcs=("$HOME/.zshrc" "$HOME/.bashrc") + for rc in "${rcs[@]}"; do [ -f "$rc" ] && value="$(rc_export_value "$var" "$rc")" if [ -n "$value" ] && [ "$value" != "@$var@" ]; then printf '%s\n' "$value"