From ef8767c5f058fc680bf46a0a60b1779165a8192b Mon Sep 17 00:00:00 2001 From: Zhaosheng Pan Date: Wed, 21 May 2025 22:41:59 +0800 Subject: [PATCH] feat(nushell)!: improve nushell support for nushell v0.96+ --- README.md | 8 +++----- z.lua | 5 ++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fe1fa8f..ff078fb 100644 --- a/README.md +++ b/README.md @@ -122,12 +122,10 @@ z -b foo bar # replace foo with bar in cwd and cd there Put something like this in your `env.nu`: - lua /path/to/z.lua --init nushell | save -f ~/.cache/zlua.nu + mkdir ($nu.data-dir | path join "vendor/autoload") + lua /path/to/z.lua --init nushell | save -f ($nu.data-dir | path join "vendor/autoload/zlua.nu") - Then put something like this in your `config.nu`: - - source ~/.cache/zlua.nu - alias z = _zlua + Note: Only Nushell v0.96+ is supported - Power Shell: diff --git a/z.lua b/z.lua index ed15c1b..662692a 100755 --- a/z.lua +++ b/z.lua @@ -2814,7 +2814,7 @@ end -- nushell ----------------------------------------------------------------------- local script_zlua_nushell = [[ -def _zlua --env --wrapped [...args: string] { +export def _zlua --env --wrapped [...args: string] { if ($args | length) != 0 and $args.0 == "--add" { with-env { _ZL_RANDOM: (random int) } { ^$env.ZLUA_LUAEXE $env.ZLUA_SCRIPT --add ...($args | skip 1) } } else if ($args | length) != 0 and $args.0 == "--complete" { @@ -2899,6 +2899,9 @@ if completer in $env.config.completions.external { } }) } + +export alias z = _zlua + ]] -----------------------------------------------------------------------