mirror of
https://github.com/skywind3000/z.lua
synced 2026-03-23 08:09:49 +00:00
update doc
This commit is contained in:
57
README.cn.md
57
README.cn.md
@@ -18,7 +18,7 @@ z.lua 是一个快速路径切换工具,它会跟踪你在 shell 下访问过
|
||||
- 使用增强匹配算法,更准确的带你去到你想去的地方。
|
||||
- 低占用,能够仅在当前路径改变时才更新数据库(将 `$_ZL_ADD_ONCE` 设成 1)。
|
||||
- 交互选择模式,如果有多个匹配结果的话,跳转前允许你进行选择。
|
||||
- 交互选择模式,支持使用 fzf 进行可视化结果筛选(可选)。
|
||||
- 集成 fzf (可选),可以用来做可视化选择或者 bash 参数补全。
|
||||
- 快速跳转到父目录,或者项目根目录,代替反复 “cd ../../.." 。
|
||||
- 兼容 lua 5.1, 5.2 和 5.3 以上版本。
|
||||
- 自包含且无额外依赖,单个 `z.lua` 文件完成所有工作。
|
||||
@@ -312,6 +312,30 @@ $ ls -l `zb git`
|
||||
**Bonus**:`zb ..` 相当于 `cd ..`,`zb ...` 相当于 `cd ../..`,而 `zb ....` 相当于 `cd ../../..` 等等。 最后 `zb ..20` 等同于调用 `cd ..` 二十次。
|
||||
|
||||
|
||||
## 补全功能
|
||||
|
||||
zsh/fish 的补全系统是比较完善的,使用 `z foo<tab>` 就能触发补全,显示一个列表:
|
||||
|
||||

|
||||
|
||||
再次按 `<tab>` 键,就可以用可视化的方式对列表进行选择。
|
||||
|
||||
在 bash 下面补全系统没有那么强大,所以 z.lua 引入了 fzf 补全,初始化使用:
|
||||
|
||||
```bash
|
||||
eval "$(lua /path/to/z.lua --init bash enhanced once echo fzf)"
|
||||
```
|
||||
|
||||
然后你在 bash 中,输入部分关键字后按 tab,就能把匹配的路径列出来:
|
||||
|
||||

|
||||
|
||||
有了 fzf 的帮助,bash 下补全也非常方便了。
|
||||
|
||||
注意:该功能在初始化 z.lua 之前,会检测 $PATH 中是否有 fzf 这个程序,有的话才启用。
|
||||
|
||||
|
||||
|
||||
## Tips
|
||||
|
||||
推荐一些常用的命令别名:
|
||||
@@ -323,6 +347,21 @@ alias zf='z -I' # 使用 fzf 对多个结果进行选择
|
||||
alias zb='z -b' # 快速回到父目录
|
||||
```
|
||||
|
||||
导入 z.sh 的数据:
|
||||
|
||||
|
||||
```bash
|
||||
cat ~/.z >> ~/.zlua
|
||||
```
|
||||
|
||||
导入 autojump 的数据:
|
||||
|
||||
```bash
|
||||
FN="$HOME/.local/share/autojump/autojump.txt"
|
||||
awk -F '\t' '{print $2 "|" $1 "|" 0}' $FN >> ~/.zlua
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## Benchmark
|
||||
@@ -361,22 +400,6 @@ sys 0m0.030s
|
||||
|
||||
最关键的一点,Lua 可以方便的兼容 Windows cmd 以及 cmder 和 ConEmu。
|
||||
|
||||
## Import database
|
||||
|
||||
导入 z.sh 的数据文件很简单,格式是一样的:
|
||||
|
||||
|
||||
```bash
|
||||
cat ~/.z >> ~/.zlua
|
||||
```
|
||||
|
||||
导入 autojump 数据文件需要稍微转换下:
|
||||
|
||||
```bash
|
||||
FN="$HOME/.local/share/autojump/autojump.txt"
|
||||
awk -F '\t' '{print $2 "|" $1 "|" 0}' $FN >> ~/.zlua
|
||||
```
|
||||
|
||||
|
||||
## Credit
|
||||
|
||||
|
||||
55
README.md
55
README.md
@@ -22,7 +22,7 @@ For example, `z foo bar` would match `/foo/bar` but not `/bar/foo`.
|
||||
- Enhanced matching mode 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.
|
||||
- Interactive selection with FZF (optional).
|
||||
- Intergrated with FZF (optional) for interactive selection and bash completion.
|
||||
- Quickly go back to a parent directory instead of typing "cd ../../..".
|
||||
- Corresponding experience in different shells and operating systems.
|
||||
- Compatible with Lua 5.1, 5.2 and 5.3+
|
||||
@@ -277,6 +277,7 @@ Usually, `z -I` can be aliased to `zf` (z + fuzzy finder) for convenience. If th
|
||||
|
||||
NOTE: For fish shell, this feature requires fish 2.7.0 or above. You can specify fzf executable in `$_ZL_FZF` environment variable, `"fzf"` will be called by default.
|
||||
|
||||
|
||||
## Jump Backwards
|
||||
|
||||
New option `"-b"` can quickly go back to a specific parent directory in bash instead of typing "cd ../../.." redundantly.
|
||||
@@ -329,6 +330,29 @@ $ ls -l `zb git`
|
||||
**Bonus**: `zb ..` equals to `cd ..`, `zb ...` equals to `cd ../..` and `zb ....` equals to `cd ../../..`, and so on. Finally, `zb ..20` equals to `cd (..)x20`.
|
||||
|
||||
|
||||
## Completion
|
||||
|
||||
For zsh/fish, completion can be triggered by `z foo<tab>`. and a list of candidates will display in zsh / fish:
|
||||
|
||||

|
||||
|
||||
Press `<tab>` again, you can select your destination in a visualized way.
|
||||
|
||||
Bash is not as powerful as zsh/fish, so we introduced fzf-completion for bash, initialize your z.lua like this:
|
||||
|
||||
```bash
|
||||
eval "$(lua /path/to/z.lua --init bash enhanced once echo fzf)"
|
||||
```
|
||||
|
||||
Then press `<tab>` after `z xxx`:
|
||||
|
||||

|
||||
|
||||
With the help of fzf, completion in bash is much easier now.
|
||||
|
||||
NOTE: To enable this, command `fzf` must be found in `$PATH` before initialization.
|
||||
|
||||
|
||||
## Tips
|
||||
|
||||
Recommended aliases you may find useful:
|
||||
@@ -340,6 +364,20 @@ alias zf='z -I' # use fzf to select in multiple matches
|
||||
alias zb='z -b' # quickly cd to the parent directory
|
||||
```
|
||||
|
||||
Import data from z.sh:
|
||||
|
||||
|
||||
```bash
|
||||
cat ~/.z >> ~/.zlua
|
||||
```
|
||||
|
||||
Import data from autojump:
|
||||
|
||||
```bash
|
||||
FN="$HOME/.local/share/autojump/autojump.txt"
|
||||
awk -F '\t' '{print $2 "|" $1 "|" 0}' $FN >> ~/.zlua
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Benchmark
|
||||
@@ -371,21 +409,6 @@ sys 0m0.030s
|
||||
As you see, z.lua is the fastest one and requires less resource.
|
||||
|
||||
|
||||
## Import Database
|
||||
|
||||
You can import your datafile from z.sh by:
|
||||
|
||||
|
||||
```bash
|
||||
cat ~/.z >> ~/.zlua
|
||||
```
|
||||
|
||||
Import datafile from autojump by:
|
||||
|
||||
```bash
|
||||
FN="$HOME/.local/share/autojump/autojump.txt"
|
||||
awk -F '\t' '{print $2 "|" $1 "|" 0}' $FN >> ~/.zlua
|
||||
```
|
||||
|
||||
## Reputation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user