Skip to content

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

# `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

@kabouzeid
Copy link

I also just ran into this problem. Is there a blocker why this is not merged yet?

@krobelus
Copy link

krobelus commented Oct 5, 2025 via email

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

4 participants