1
0
mirror of https://github.com/skywind3000/z.lua synced 2026-03-22 15:49:47 +00:00

6 Commits

Author SHA1 Message Date
skywind3000
3482460bd2 update version number 2025-05-24 23:05:00 +08:00
Linwei
bcb5599c12 Merge pull request #221 from brglng/feature/nushell
feat(nushell)!: improve nushell support for nushell v0.96+
2025-05-21 23:37:24 +08:00
Zhaosheng Pan
ef8767c5f0 feat(nushell)!: improve nushell support for nushell v0.96+ 2025-05-21 22:45:12 +08:00
skywind3000
23aeabedd9 update version number 2025-05-18 00:18:33 +08:00
Linwei
27dceb9899 Merge pull request #219 from chrisant996/allow_interactive_with_no_args
Fix when _ZL_MATCH_MODE=1.
2025-05-18 00:16:39 +08:00
Chris Antos
19b2d1747e Fix when _ZL_MATCH_MODE=1. 2025-05-17 04:29:40 -07:00
2 changed files with 10 additions and 11 deletions

View File

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

13
z.lua
View File

@@ -4,7 +4,7 @@
-- z.lua - a cd command that learns, by skywind 2018-2022
-- Licensed under MIT license.
--
-- Version 1.8.22, Last Modified: 2025/05/17 13:54:38
-- Version 1.8.24, Last Modified: 2025/05/24 23:04:42
--
-- * 10x faster than fasd and autojump, 3x faster than z.sh
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
@@ -1979,7 +1979,7 @@ function main(argv)
path = z_cd(args)
if path == nil and Z_MATCHMODE ~= 0 then
local last = args[#args]
if os.path.isdir(last) then
if last and os.path.isdir(last) then
path = os.path.abspath(last)
path = os.path.norm(path)
end
@@ -2655,9 +2655,7 @@ if /i "%1"=="--purge" (
)
:check
if /i "%1"=="" (
if /i "%InterMode%"=="" (
set "RunMode=-l"
)
set "RunMode=-l"
)
for /f "delims=" %%i in ('cd') do set "PWD=%%i"
if /i "%RunMode%"=="-n" (
@@ -2814,7 +2812,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 +2897,9 @@ if completer in $env.config.completions.external {
}
})
}
export alias z = _zlua
]]
-----------------------------------------------------------------------