diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 7a3604be9..c578d2378 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1960,6 +1960,19 @@ in { as well as wf-shell. ''; } + + { + time = "2025-01-21T17:28:13+00:00"; + condition = with config.programs.yazi; enable && enableFishIntegration; + message = '' + Yazi's fish shell integration wrapper now calls the 'yazi' executable + directly, ignoring any shell aliases with the same name. + + Your configuration may break if you rely on the wrapper calling a + 'yazi' alias. + ''; + } ]; }; } + diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 314c4c5ed..a17f2952e 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -18,14 +18,12 @@ let ''; fishIntegration = '' - function ${cfg.shellWrapperName} - set tmp (mktemp -t "yazi-cwd.XXXXX") - yazi $argv --cwd-file="$tmp" - if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] - builtin cd -- "$cwd" - end - rm -f -- "$tmp" + set -l tmp (mktemp -t "yazi-cwd.XXXXX") + command yazi $argv --cwd-file="$tmp" + if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] + builtin cd -- "$cwd" end + rm -f -- "$tmp" ''; nushellIntegration = '' @@ -202,7 +200,7 @@ in { programs.zsh.initExtra = mkIf cfg.enableZshIntegration bashIntegration; - programs.fish.interactiveShellInit = + programs.fish.functions.${cfg.shellWrapperName} = mkIf cfg.enableFishIntegration fishIntegration; programs.nushell.extraConfig = diff --git a/tests/modules/programs/yazi/fish-integration-enabled.nix b/tests/modules/programs/yazi/fish-integration-enabled.nix index 2231035b9..8e54e5e7a 100644 --- a/tests/modules/programs/yazi/fish-integration-enabled.nix +++ b/tests/modules/programs/yazi/fish-integration-enabled.nix @@ -1,27 +1,18 @@ -{ ... }: +{ config, ... }: -let - shellIntegration = '' - function yy - set tmp (mktemp -t "yazi-cwd.XXXXX") - yazi $argv --cwd-file="$tmp" - if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] - builtin cd -- "$cwd" - end - rm -f -- "$tmp" - end - ''; -in { +{ programs.fish.enable = true; programs.yazi = { enable = true; + shellWrapperName = "yy"; enableFishIntegration = true; }; test.stubs.yazi = { }; nmt.script = '' - assertFileContains home-files/.config/fish/config.fish '${shellIntegration}' + assertFileContent home-files/.config/fish/functions/${config.programs.yazi.shellWrapperName}.fish \ + ${./fish-integration-expected.fish} ''; } diff --git a/tests/modules/programs/yazi/fish-integration-expected.fish b/tests/modules/programs/yazi/fish-integration-expected.fish new file mode 100644 index 000000000..d8f11f284 --- /dev/null +++ b/tests/modules/programs/yazi/fish-integration-expected.fish @@ -0,0 +1,8 @@ +function yy + set -l tmp (mktemp -t "yazi-cwd.XXXXX") + command yazi $argv --cwd-file="$tmp" + if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] + builtin cd -- "$cwd" + end + rm -f -- "$tmp" +end