Skip to content

Update zoxide to support Fish 4.1.x #1046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

talios
Copy link

@talios talios commented Apr 28, 2025

This commit updates the fish init script to support the upcoming 4.1.x release of Fish by using status get-file.

Fixes #1045

This commit updates the fish init script to support the upcoming 4.1.x
release of Fish by using `status get-file`.

Fixes ajeetdsouza#1045
@@ -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)
Copy link

@faho faho Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Piping to source like above (and to string) is fine, shorter and works better:

status get-file functions/cd.fish | string replace --regex -- '^function cd\s' 'function __zoxide_cd_internal ' | source

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to piping and reverted the 3.x case to the original.

@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also needs 2>/dev/null (could use the &>/dev/null shorthand),
else it will print an error on fish version 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Fish 4.1.x
3 participants