Skip to content

Commit 0b159b6

Browse files
author
skywind3000
committed
1.5.2: be aware of all arguments in fzf completion
1 parent 6e330ab commit 0b159b6

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -343,21 +343,7 @@ NOTE: To enable this, command `fzf` must be found in `$PATH` before initializati
343343

344344
## Most Recently Accessed Path
345345

346-
We always use `cd -` to go back to last accessed directory, but with the help of `fzf` we can achieve this productively:
347-
348-
```bash
349-
alias zh='z -I -t .'
350-
```
351-
352-
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:
353-
354-
![](images/mru.png)
355-
356-
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.
357-
358-
At last, press `<enter>` to accept or `<ESC>` to give up.
359-
360-
Version `v1.5.1` has introduced a simulated "dirstack", which can be manipulated by `z -`, `z --` and `z -{num}`:
346+
`z.lua` provides a fast way to visit MRU directories without typing any keyword. That is `dirstack`, which records recently visited paths and can be manipulated by `z -`, `z --` and `z -{num}`:
361347

362348
```bash
363349
# display current dir stack
@@ -377,7 +363,24 @@ $ z -
377363
=> cd -
378364
```
379365

380-
The dirstack is calculated from z.lua's database, and has no dependency on shells or systems. You will not lost records after re-login, and history can be shared across shells and sessions.
366+
The `dirstack` is calculated from z.lua's database, and has no dependency on shells or systems. You will not lost records after re-login, and history can be shared across shells and sessions.
367+
368+
There is another way to access MRU directories interactively by utilizing parameter `-I` (fzf) and `-t` (sort by time):
369+
370+
```bash
371+
alias zh='z -I -t .'
372+
```
373+
374+
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:
375+
376+
![](images/mru.png)
377+
378+
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.
379+
380+
At last, press `<enter>` to accept or `<ESC>` to give up.
381+
382+
Version `v1.5.1` has introduced a simulated "dirstack", which can be manipulated by `z -`, `z --` and `z -{num}`:
383+
381384

382385
Remember to enable the [enhanced matching](#enhanced-matching) algorithm, the current working directory can be skipped with it.
383386

@@ -450,6 +453,7 @@ As you see, z.lua is the fastest one and requires less resource.
450453

451454
## History
452455

456+
- 1.5.2 (2019-02-16): be aware of all arguments in fzf completion.
453457
- 1.5.1 (2019-02-15): new: simulated dir stack by `z -`, `z --` and `z -{num}`.
454458
- 1.5.0 (2019-02-14): fixed minor issues in backward jumping.
455459
- 1.4.7 (2019-02-13): Don't use regex in backward jumping (use plain text instead).

z.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- z.lua - a cd command that learns, by skywind 2018, 2019
55
-- Licensed under MIT license.
66
--
7-
-- Version 1.5.1, Last Modified: 2019/02/15 11:26
7+
-- Version 1.5.2, Last Modified: 2019/02/16 14:25
88
--
99
-- * 10x faster than fasd and autojump, 3x faster than z.sh
1010
-- * available for posix shells: bash, zsh, sh, ash, dash, busybox
@@ -1900,8 +1900,7 @@ if [ "$TERM" != "dumb" ] && command -v fzf >/dev/null 2>&1; then
19001900
# To redraw line after fzf closes (printf '\e[5n')
19011901
bind '"\e[0n": redraw-current-line'
19021902
_zlua_fzf_complete() {
1903-
local query="${COMP_WORDS[COMP_CWORD]}"
1904-
local selected=$(_zlua | sed "s|$HOME|\~|" | $zlua_fzf --query "$query" | sed 's/^[0-9,.]* *//')
1903+
local selected=$(_zlua -l "${COMP_WORDS[@]:1}" | sed "s|$HOME|\~|" | $zlua_fzf | sed 's/^[0-9,.]* *//')
19051904
if [ -n "$selected" ]; then
19061905
COMPREPLY=( "$selected" )
19071906
fi

0 commit comments

Comments
 (0)