From 92a26bf6df1f00cbbed16a99d2547531ff4b3a83 Mon Sep 17 00:00:00 2001 From: eljamm Date: Sun, 23 Jun 2024 15:05:25 +0100 Subject: [PATCH] yazi: add shellWrapperName & rename wrappers to yy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The program shell wrappers have been renamed from `ya` to `yy` following the introduction of the new CLI tool named `ya`. With this in mind, the `shellWrapperName` option has been introduced to provide users with more flexibility in choosing the name they're most accustomed to (ra, lf, ...). Co-authored-by: XYenon Co-authored-by: 三咲雅 · Misaki Masa --- modules/misc/news.nix | 13 +++++++++++++ modules/programs/yazi.nix | 15 ++++++++++++--- .../programs/yazi/bash-integration-enabled.nix | 2 +- .../programs/yazi/fish-integration-enabled.nix | 2 +- .../programs/yazi/nushell-integration-enabled.nix | 2 +- .../programs/yazi/zsh-integration-enabled.nix | 2 +- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 997c7815..e7e582f5 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 77acfc6b..105bbec4 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 ac2e4979..474a989f 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 6d2b9fa3..2231035b 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 9adbaa98..a2de2d8b 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 d5090a6a..0c0ec217 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