From d6bb9f934f2870e5cbc5b94c79e9db22246141ff Mon Sep 17 00:00:00 2001 From: XYenon Date: Tue, 27 Feb 2024 07:00:56 +0800 Subject: [PATCH] yazi: update shell integrations (#5048) (cherry picked from commit 1d085ea4444d26aa52297758b333b449b2aa6fca) --- modules/programs/yazi.nix | 12 ++++-------- .../programs/yazi/bash-integration-enabled.nix | 2 +- .../programs/yazi/nushell-integration-enabled.nix | 10 +++------- .../programs/yazi/zsh-integration-enabled.nix | 2 +- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index d0d941d1..c4534227 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -8,7 +8,7 @@ let bashIntegration = '' function ya() { - tmp="$(mktemp -t "yazi-cwd.XXXXX")" + local tmp="$(mktemp -t "yazi-cwd.XXXXX")" yazi "$@" --cwd-file="$tmp" if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then cd -- "$cwd" @@ -29,18 +29,14 @@ let ''; nushellIntegration = '' - def --env ya [args?] { + def --env ya [...args] { let tmp = (mktemp -t "yazi-cwd.XXXXX") - if ($args == null) { - yazi --cwd-file $tmp - } else { - yazi $args --cwd-file $tmp - } + yazi ...$args --cwd-file $tmp let cwd = (open $tmp) if $cwd != "" and $cwd != $env.PWD { cd $cwd } - rm -f $tmp + rm -fp $tmp } ''; in { diff --git a/tests/modules/programs/yazi/bash-integration-enabled.nix b/tests/modules/programs/yazi/bash-integration-enabled.nix index 9a8c18bf..ff9bc2f2 100644 --- a/tests/modules/programs/yazi/bash-integration-enabled.nix +++ b/tests/modules/programs/yazi/bash-integration-enabled.nix @@ -3,7 +3,7 @@ let shellIntegration = '' function ya() { - tmp="$(mktemp -t "yazi-cwd.XXXXX")" + local tmp="$(mktemp -t "yazi-cwd.XXXXX")" yazi "$@" --cwd-file="$tmp" if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then cd -- "$cwd" diff --git a/tests/modules/programs/yazi/nushell-integration-enabled.nix b/tests/modules/programs/yazi/nushell-integration-enabled.nix index 121e2756..ddd041dc 100644 --- a/tests/modules/programs/yazi/nushell-integration-enabled.nix +++ b/tests/modules/programs/yazi/nushell-integration-enabled.nix @@ -2,18 +2,14 @@ let shellIntegration = '' - def --env ya [args?] { + def --env ya [...args] { let tmp = (mktemp -t "yazi-cwd.XXXXX") - if ($args == null) { - yazi --cwd-file $tmp - } else { - yazi $args --cwd-file $tmp - } + yazi ...$args --cwd-file $tmp let cwd = (open $tmp) if $cwd != "" and $cwd != $env.PWD { cd $cwd } - rm -f $tmp + rm -fp $tmp } ''; in { diff --git a/tests/modules/programs/yazi/zsh-integration-enabled.nix b/tests/modules/programs/yazi/zsh-integration-enabled.nix index ef7960c5..c8744146 100644 --- a/tests/modules/programs/yazi/zsh-integration-enabled.nix +++ b/tests/modules/programs/yazi/zsh-integration-enabled.nix @@ -3,7 +3,7 @@ let shellIntegration = '' function ya() { - tmp="$(mktemp -t "yazi-cwd.XXXXX")" + local tmp="$(mktemp -t "yazi-cwd.XXXXX")" yazi "$@" --cwd-file="$tmp" if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then cd -- "$cwd"