diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 997c7815f..e7e582f5c 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1679,6 +1679,19 @@ in { https://github.com/rafaelmardojai/blanket for more. ''; } + + { + time = "2024-06-26T07:07:17+00:00"; + condition = with config.programs.yazi; + enable && (enableBashIntegration || enableZshIntegration + || enableFishIntegration || enableNushellIntegration); + message = '' + Yazi's shell integration wrappers have been renamed from 'ya' to 'yy'. + + A new option `programs.yazi.shellWrapperName` is also available that + allows you to override this name. + ''; + } ]; }; } diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 77acfc6ba..105bbec4d 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -7,7 +7,7 @@ let tomlFormat = pkgs.formats.toml { }; bashIntegration = '' - function ya() { + function ${cfg.shellWrapperName}() { local tmp="$(mktemp -t "yazi-cwd.XXXXX")" yazi "$@" --cwd-file="$tmp" if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then @@ -18,7 +18,7 @@ let ''; fishIntegration = '' - function ya + 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" ] @@ -29,7 +29,7 @@ let ''; nushellIntegration = '' - def --env ya [...args] { + def --env ${cfg.shellWrapperName} [...args] { let tmp = (mktemp -t "yazi-cwd.XXXXX") yazi ...$args --cwd-file $tmp let cwd = (open $tmp) @@ -47,6 +47,15 @@ in { package = mkPackageOption pkgs "yazi" { }; + shellWrapperName = mkOption { + type = types.str; + default = "yy"; + example = "y"; + description = '' + Name of the shell wrapper to be called. + ''; + }; + enableBashIntegration = mkEnableOption "Bash integration"; enableZshIntegration = mkEnableOption "Zsh integration"; diff --git a/tests/modules/programs/yazi/bash-integration-enabled.nix b/tests/modules/programs/yazi/bash-integration-enabled.nix index ac2e49796..474a989f9 100644 --- a/tests/modules/programs/yazi/bash-integration-enabled.nix +++ b/tests/modules/programs/yazi/bash-integration-enabled.nix @@ -2,7 +2,7 @@ let shellIntegration = '' - function ya() { + function yy() { local tmp="$(mktemp -t "yazi-cwd.XXXXX")" yazi "$@" --cwd-file="$tmp" if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then diff --git a/tests/modules/programs/yazi/fish-integration-enabled.nix b/tests/modules/programs/yazi/fish-integration-enabled.nix index 6d2b9fa31..2231035b9 100644 --- a/tests/modules/programs/yazi/fish-integration-enabled.nix +++ b/tests/modules/programs/yazi/fish-integration-enabled.nix @@ -2,7 +2,7 @@ let shellIntegration = '' - function ya + 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" ] diff --git a/tests/modules/programs/yazi/nushell-integration-enabled.nix b/tests/modules/programs/yazi/nushell-integration-enabled.nix index 9adbaa982..a2de2d8b7 100644 --- a/tests/modules/programs/yazi/nushell-integration-enabled.nix +++ b/tests/modules/programs/yazi/nushell-integration-enabled.nix @@ -2,7 +2,7 @@ let shellIntegration = '' - def --env ya [...args] { + def --env yy [...args] { let tmp = (mktemp -t "yazi-cwd.XXXXX") yazi ...$args --cwd-file $tmp let cwd = (open $tmp) diff --git a/tests/modules/programs/yazi/zsh-integration-enabled.nix b/tests/modules/programs/yazi/zsh-integration-enabled.nix index d5090a6a8..0c0ec217f 100644 --- a/tests/modules/programs/yazi/zsh-integration-enabled.nix +++ b/tests/modules/programs/yazi/zsh-integration-enabled.nix @@ -2,7 +2,7 @@ let shellIntegration = '' - function ya() { + function yy() { local tmp="$(mktemp -t "yazi-cwd.XXXXX")" yazi "$@" --cwd-file="$tmp" if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then