yazi: improve fish integration

Calls yazi as `command yazi`, allowing to use "yazi" as
`shellWrapperName`. Also defines the wrapper with
`programs.fish.functions` instead of `interactiveShellInit`.
This commit is contained in:
Ismaïl Senhaji 2025-01-14 17:52:56 +01:00 committed by Robert Helgesson
parent 96dee79b17
commit 4481a16d1a
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
4 changed files with 32 additions and 22 deletions

View file

@ -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}
'';
}

View file

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