From 01ddd63c143df296361fa9f7d3255de6a02fd9f8 Mon Sep 17 00:00:00 2001 From: skywind3000 Date: Mon, 11 Feb 2019 13:43:02 +0800 Subject: [PATCH] update doc: go back to MRU --- README.cn.md | 17 +++++++++++++++++ README.md | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/README.cn.md b/README.cn.md index 0ac3812..e798303 100644 --- a/README.cn.md +++ b/README.cn.md @@ -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 diff --git a/README.md b/README.md index 56c5924..3d4613e 100644 --- a/README.md +++ b/README.md @@ -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 ``/`` (as well as `CTRL+j/k`) to move the selector (red `>`) up and down. + +At last, press `` to accept or `` 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: