Skip to content

Commit 2f9ec29

Browse files
committed
Refactor Fish shell setup in README and help.sh to use cache initialization
- Update Fish setup instructions to use a cached initialization file instead of direct command execution. - Implement checks for the existence of the cache file before attempting to initialize, improving robustness. - Ensure compatibility with users who have set -e in their shell configuration by adding error handling to source commands.
1 parent eb0339d commit 2f9ec29

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ _gtr_init="${XDG_CACHE_HOME:-$HOME/.cache}/gtr/init-gtr.zsh"
225225
source "$_gtr_init" 2>/dev/null || true; unset _gtr_init
226226

227227
# Fish (add to ~/.config/fish/config.fish)
228-
git gtr init fish | source
228+
set -l _gtr_init (test -n "$XDG_CACHE_HOME" && echo $XDG_CACHE_HOME || echo $HOME/.cache)/gtr/init-gtr.fish
229+
test -f "$_gtr_init"; or git gtr init fish >/dev/null 2>&1
230+
source "$_gtr_init" 2>/dev/null
229231

230232
# Then navigate with:
231233
gtr cd # Interactive worktree picker (requires fzf)

lib/commands/help.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,9 @@ Setup (sources cached output directly for fast startup):
369369
source "$_gtr_init" 2>/dev/null || true; unset _gtr_init
370370
371371
# Fish (add to ~/.config/fish/config.fish)
372-
git gtr init fish | source
372+
set -l _gtr_init (test -n "$XDG_CACHE_HOME" && echo $XDG_CACHE_HOME || echo $HOME/.cache)/gtr/init-gtr.fish
373+
test -f "$_gtr_init"; or git gtr init fish >/dev/null 2>&1
374+
source "$_gtr_init" 2>/dev/null
373375
374376
# Custom function name (avoids conflict with coreutils gtr)
375377
eval "$(git gtr init zsh --as gwtr)"

0 commit comments

Comments
 (0)