mirror of
https://github.com/skywind3000/z.lua
synced 2026-03-22 15:49:47 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6025da3ae5 | ||
|
|
1ebe5bcaa7 | ||
|
|
e1eb7a2104 | ||
|
|
f80e22498c | ||
|
|
ce1ee31529 | ||
|
|
aebea97d8e | ||
|
|
314dd0a29d | ||
|
|
3482460bd2 | ||
|
|
bcb5599c12 | ||
|
|
ef8767c5f0 | ||
|
|
23aeabedd9 | ||
|
|
27dceb9899 | ||
|
|
19b2d1747e |
@@ -14,7 +14,7 @@ z.lua 是一个快速路径切换工具,它会跟踪你在 shell 下访问过
|
||||
|
||||
- 性能比 **z.sh** 快三倍,比 **fasd** / **autojump** 快十倍以上。
|
||||
- 支持 Posix Shell:bash, zsh, dash, sh, ash, busybox 等等。
|
||||
- 支持 Fish Shell,Power Shell 和 Windows cmd。
|
||||
- 支持 Fish Shell,Nushell, 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:
|
||||
|
||||
|
||||
23
README.md
23
README.md
@@ -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
16
z.lua
@@ -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
|
||||
|
||||
]]
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user