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

13 Commits

Author SHA1 Message Date
skywind3000
6025da3ae5 fix: don't reassign for-loop variable 2026-03-09 21:15:58 +08:00
Linwei
1ebe5bcaa7 Merge pull request #228 from botantony/lua-5.5-patch
fix: don't reassign for-loop variable
2025-12-24 17:47:50 +08:00
botantony
e1eb7a2104 fix: don't reassign for-loop variable
In Lua 5.5 you can no longer reassign for-loop variables, f.e.

```lua
for k, v in pairs(tbl) do k = "foobar" end
```

This PR should fix this problem

Signed-off-by: botantony <antonsm21@gmail.com>
2025-12-23 22:49:39 +01:00
Linwei
f80e22498c Merge pull request #223 from fabiob/patch-1
Adds NixOS instructions to README.md
2025-08-01 14:42:55 +08:00
Fábio D. Batista
ce1ee31529 Adds NixOS instructions to README.md 2025-07-31 18:18:15 -03:00
Linwei
aebea97d8e Merge pull request #222 from brglng/feature/nushell
fix: installation instructions in README.md
2025-05-29 21:52:11 +08:00
Zhaosheng Pan
314dd0a29d fix: installation instructions in README.md 2025-05-29 17:37:09 +08:00
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
3 changed files with 31 additions and 11 deletions

View File

@@ -14,7 +14,7 @@ z.lua 是一个快速路径切换工具,它会跟踪你在 shell 下访问过
- 性能比 **z.sh** 快三倍,比 **fasd** / **autojump** 快十倍以上。
- 支持 Posix Shellbash, zsh, dash, sh, ash, busybox 等等。
- 支持 Fish ShellPower Shell 和 Windows cmd。
- 支持 Fish ShellNushell, Power Shell 和 Windows cmd。
- 使用增强匹配算法,更准确的带你去到你想去的地方。
- 低占用,能够仅在当前路径改变时才更新数据库(将 `$_ZL_ADD_ONCE` 设成 1
- 交互选择模式,如果有多个匹配结果的话,跳转前允许你进行选择。
@@ -93,7 +93,6 @@ z -b foo # 跳转到父目录中名称以 foo 开头的那一级
然后在 `config.nu` 中加入如下代码:
source ~/.cache/zlua.nu
alias z = _zlua
- Power Shell:

View File

@@ -28,7 +28,7 @@ From people using z.lua:
- **10x** times faster than **fasd** and **autojump**, **3x** times faster than **z.sh**.
- Gain the ultimate speed with an optional [native module](https://github.com/skywind3000/czmod) written in C.
- Available for **posix shells**: bash, zsh, dash, sh, ash, ksh, busybox and etc.
- Available for Fish Shell, Power Shell and Windows cmd.
- Available for Fish Shell, Nushell, Power Shell and Windows cmd.
- [Enhanced matching algorithm](#enhanced-matching) takes you to where ever you want precisely.
- Allow updating database only if `$PWD` changed with "$_ZL_ADD_ONCE" set to 1.
- Interactive selection enables you to choose where to go before cd.
@@ -78,6 +78,12 @@ z -b foo bar # replace foo with bar in cwd and cd there
eval "$(lua /path/to/z.lua --init bash enhanced once fzf)"
NixOS users using home-manager can add this to their user profile:
programs.z-lua.enable = true;
programs.z-lua.enableBashIntegration = true;
programs.z-lua.options = [ "enhanced" "once" "fzf" ]; # modify as needed
**NOTE**: For wsl-1 users, `lua-filesystem` must be installed:
sudo apt-get install lua-filesystem
@@ -92,6 +98,12 @@ z -b foo bar # replace foo with bar in cwd and cd there
Options like "enhanced", "once" and "fzf" can be used after `--init` too. It can also be initialized from "skywind3000/z.lua" with your zsh plugin managers (antigen / oh-my-zsh).
NixOS users using home-manager can add this to their user profile:
programs.z-lua.enable = true;
programs.z-lua.enableZshIntegration = true;
programs.z-lua.options = [ "enhanced" "once" "fzf" ]; # modify as needed
**NOTE**: for wsl-1 users, `lua-filesystem` must be installed.
- Posix Shells:
@@ -118,6 +130,12 @@ z -b foo bar # replace foo with bar in cwd and cd there
into the same file.
NixOS users using home-manager can add this to their user profile:
programs.z-lua.enable = true;
programs.z-lua.enableFishIntegration = true;
programs.z-lua.options = [ "enhanced" "once" "fzf" ]; # modify as needed
- Nushell
Put something like this in your `env.nu`:
@@ -127,7 +145,8 @@ z -b foo bar # replace foo with bar in cwd and cd there
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:

16
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.25, Last Modified: 2026/03/09 21:15:46
--
-- * 10x faster than fasd and autojump, 3x faster than z.sh
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
@@ -235,7 +235,8 @@ end
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
for key, v in pairs(o) do
local k = key
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
@@ -1979,7 +1980,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 +2656,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 +2813,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 +2898,9 @@ if completer in $env.config.completions.external {
}
})
}
export alias z = _zlua
]]
-----------------------------------------------------------------------