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

update doc: go back to MRU

This commit is contained in:
skywind3000
2019-02-11 13:43:02 +08:00
parent 3fb6ff7aea
commit 01ddd63c14
2 changed files with 34 additions and 0 deletions

View File

@@ -335,6 +335,23 @@ eval "$(lua /path/to/z.lua --init bash enhanced once echo fzf)"
注意:该功能在初始化 z.lua 之前,会检测 $PATH 中是否有 fzf 这个程序,有的话才启用。
## MRU
以往我们经常使用 `cd -` 命令来回到刚才访问过的目录,而有了 fzf 的帮助,我们可以更高效的来完成这件事情:
```bash
alias zh=`z -t -I .`
```
首先定义个新的别名 `zh`(回到历史路径的意思),我们使用了 `-t` 参数来告诉 `z.lua` 按照时间戳作为权重进行排序,同时 `-I` 启用 fzf 进行搜索,最后的句号代表任意路径。
那么当我们在命令行敲入 zh 时,就可以用 fzf 选择仅仅呆过的路径了:
![](images/mru.png)
第一列数据代表该路径多少秒以前访问过,第二列是路径名称。此时,你可以试着敲几个字母,用 fzf 的字符串模糊匹配进行定位或者用光标键的上和下CTRL+J/K 也可以)来上下移动,最后按回车 cd 过去,或者 ESC 放弃。
## Tips

View File

@@ -352,6 +352,22 @@ 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.
## Most Recently Accessed Path
We always use `cd -` to go back to last accessed directory, but with the help of `fzf` we can achieve this productively:
```bash
alias zh=`z -t -I .`
```
The new alias `zh` (jump to history) uses a parameter `-t` to sort the result by time and `-I` to use `fzf` for selection. the result is:
![](images/mru.png)
The first column indicates how many seconds ago you have visited, and the second column is the path name. With `zh`, you can type some character to use string matching in fzf, or use `<Up>`/`<Down>` (as well as `CTRL+j/k`) to move the selector (red `>`) up and down.
At last, press `<enter>` to accept or `<ESC>` to give up.
## Tips
@@ -362,6 +378,7 @@ alias zc='z -c' # restrict matches to subdirs of $PWD
alias zz='z -i' # cd with interactive selection
alias zf='z -I' # use fzf to select in multiple matches
alias zb='z -b' # quickly cd to the parent directory
alias zh='zf -t .' # cd to MRU.
```
Import data from z.sh