Fix Fish shell auto-switching on new tab/shell startup #165
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.
Problem
When opening a new Fish shell tab in the same directory (e.g., in WezTerm or other terminal emulators), the Ruby version was not automatically set based on
.ruby-version. Users had tocdout and back into the directory to trigger the version switch.Root Cause
The Fish shell init script only defined a
--on-variable PWDhook, which triggers when the working directory changes. However, when a new shell starts in a directory,$PWDis set but never "changes", so the hook never fires.Solution
Call
_rv_autoload_hookimmediately after defining it, matching the behavior already implemented for Zsh and Bash shells. This ensures the Ruby version is activated on shell startup, not just on directory changes.Changes
crates/rv/src/commands/shell/init.rsto call_rv_autoload_hookafter function definition in Fish shellTesting
Before:
After:
Verified that opening new tabs in the same directory now correctly activates the Ruby version specified in
.ruby-version.