fix(install): detect shell rc files for ZDOTDIR and macOS login shells#24
Merged
guodong-sq merged 1 commit intoblock:mainfrom Feb 27, 2026
Merged
Conversation
The installer's configure_shell_rc() hardcoded $HOME/.zshrc and
$HOME/.bashrc, which silently failed (no snippet, no warning) when:
1. ZDOTDIR is set — zsh reads $ZDOTDIR/.zshrc, not $HOME/.zshrc.
Common with dotfile managers (chezmoi, stow) and XDG-clean setups.
2. macOS Bash with only .bash_profile — macOS terminals open login
shells, which read ~/.bash_profile not ~/.bashrc.
Changes:
- configure_shell_rc() now checks ${ZDOTDIR:-$HOME}/.zshrc for zsh
and falls back from .bashrc to .bash_profile for bash
- Warns when no rc file is found at all
- Legacy migration loop checks the same expanded set of paths
- Post-install banner dynamically shows the correct file to source
- wt.sh error messages reference the correct rc file paths
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
guodong-sq
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The installer's
configure_shell_rc()hardcoded$HOME/.zshrcand$HOME/.bashrcas the only rc files to configure. This silently did nothing (no snippet appended, no warning shown) in two common scenarios:ZDOTDIRis set — zsh reads$ZDOTDIR/.zshrc, not$HOME/.zshrc. This is common with dotfile managers (chezmoi, stow, yadm) and users who keep$HOMEclean via XDG-style layouts..bash_profile— macOS Terminal.app and iTerm2 open login shells by default, which source~/.bash_profile, not~/.bashrc. Users without a.bashrcwere silently skipped.Changes
install.sh—configure_shell_rc()ZDOTDIR: checks${ZDOTDIR:-$HOME}/.zshrc.bashrcto.bash_profile(first existing file wins)warnwhen no rc file is found at all, with the exact line to add manuallyinstall.sh— Legacy migration loopfor rc_file in ...loop that migrates.config/wt→.wtreferences now checks the same expanded set of paths:${ZDOTDIR:-$HOME}/.zshrc,$HOME/.bashrc,$HOME/.bash_profileZDOTDIRis unset, the first and second entries both resolve under$HOME; thegrepguard prevents double-processinginstall.sh— Post-install bannersource ~/.zshrc # or ~/.bashrc$HOMEprefix with~for a clean displaywt.sh—_wt_ensure_sourced()error messages~/.zshrc→${ZDOTDIR:-~}/.zshrc~/.bashrc→~/.bashrc (or ~/.bash_profile)Test plan
./test/bats/bin/bats test/unit/ test/integration/ test/e2e/— 167/168 pass (1 pre-existing failure inwt-remove --mergedunrelated to this change)ZDOTDIRto a temp dir containing a.zshrc, run installer, verify snippet lands in the correct file~/.bash_profile(no~/.bashrc), run installer, verify snippet lands in.bash_profile🤖 Generated with Claude Code