yazi: add shellWrapperName & rename wrappers to yy

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 <register@xyenon.bid>

Co-authored-by: 三咲雅 · Misaki Masa <sxyazi@gmail.com>
This commit is contained in:
eljamm 2024-06-23 15:05:25 +01:00 committed by Robert Helgesson
parent d3bf2a0612
commit 92a26bf6df
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
6 changed files with 29 additions and 7 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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