From 6f94eb5d2373aef85b7c9c943cad7305a3d8a2a8 Mon Sep 17 00:00:00 2001 From: Mark Derricutt Date: Mon, 28 Apr 2025 22:46:20 +1200 Subject: [PATCH 1/2] Update zoxide to support Fish 4.1.x This commit updates the fish init script to support the upcoming 4.1.x release of Fish by using `status get-file`. Fixes #1045 --- templates/fish.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/fish.txt b/templates/fish.txt index f6ade185a..5631694d7 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -19,7 +19,11 @@ end # A copy of fish's internal cd function. This makes it possible to use # `alias cd=z` without causing an infinite loop. if ! builtin functions --query __zoxide_cd_internal - string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' <$__fish_data_dir/functions/cd.fish | source + if status list-files functions/cd.fish >/dev/null + source (string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' (status get-file functions/cd.fish) | psub -f) + else + source (string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' (cat $__fish_data_dir/functions/cd.fish) | psub -f) + end end # cd + custom logic based on the value of _ZO_ECHO. From 48e40a6346ecf86b25bc53abc86de6c21b35ef23 Mon Sep 17 00:00:00 2001 From: Mark Derricutt Date: Tue, 29 Apr 2025 07:52:28 +1200 Subject: [PATCH 2/2] Reverted to piping, and fixed redirection --- templates/fish.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/fish.txt b/templates/fish.txt index 5631694d7..038e08eac 100644 --- a/templates/fish.txt +++ b/templates/fish.txt @@ -19,10 +19,10 @@ end # A copy of fish's internal cd function. This makes it possible to use # `alias cd=z` without causing an infinite loop. if ! builtin functions --query __zoxide_cd_internal - if status list-files functions/cd.fish >/dev/null - source (string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' (status get-file functions/cd.fish) | psub -f) + if status list-files functions/cd.fish &>/dev/null + status get-file functions/cd.fish | string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' | source else - source (string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' (cat $__fish_data_dir/functions/cd.fish) | psub -f) + string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' <$__fish_data_dir/functions/cd.fish | source end end