mirror of
https://github.com/skywind3000/z.lua
synced 2026-03-14 19:59:48 +00:00
1.5.2: be aware of all arguments in fzf completion
This commit is contained in:
36
README.md
36
README.md
@@ -343,21 +343,7 @@ NOTE: To enable this, command `fzf` must be found in `$PATH` before initializati
|
||||
|
||||
## 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 -I -t .'
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||
Version `v1.5.1` has introduced a simulated "dirstack", which can be manipulated by `z -`, `z --` and `z -{num}`:
|
||||
`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}`:
|
||||
|
||||
```bash
|
||||
# display current dir stack
|
||||
@@ -377,7 +363,24 @@ $ z -
|
||||
=> cd -
|
||||
```
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
There is another way to access MRU directories interactively by utilizing parameter `-I` (fzf) and `-t` (sort by time):
|
||||
|
||||
```bash
|
||||
alias zh='z -I -t .'
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||
Version `v1.5.1` has introduced a simulated "dirstack", which can be manipulated by `z -`, `z --` and `z -{num}`:
|
||||
|
||||
|
||||
Remember to enable the [enhanced matching](#enhanced-matching) algorithm, the current working directory can be skipped with it.
|
||||
|
||||
@@ -450,6 +453,7 @@ As you see, z.lua is the fastest one and requires less resource.
|
||||
|
||||
## History
|
||||
|
||||
- 1.5.2 (2019-02-16): be aware of all arguments in fzf completion.
|
||||
- 1.5.1 (2019-02-15): new: simulated dir stack by `z -`, `z --` and `z -{num}`.
|
||||
- 1.5.0 (2019-02-14): fixed minor issues in backward jumping.
|
||||
- 1.4.7 (2019-02-13): Don't use regex in backward jumping (use plain text instead).
|
||||
|
||||
5
z.lua
5
z.lua
@@ -4,7 +4,7 @@
|
||||
-- z.lua - a cd command that learns, by skywind 2018, 2019
|
||||
-- Licensed under MIT license.
|
||||
--
|
||||
-- Version 1.5.1, Last Modified: 2019/02/15 11:26
|
||||
-- Version 1.5.2, Last Modified: 2019/02/16 14:25
|
||||
--
|
||||
-- * 10x faster than fasd and autojump, 3x faster than z.sh
|
||||
-- * 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
|
||||
# To redraw line after fzf closes (printf '\e[5n')
|
||||
bind '"\e[0n": redraw-current-line'
|
||||
_zlua_fzf_complete() {
|
||||
local query="${COMP_WORDS[COMP_CWORD]}"
|
||||
local selected=$(_zlua | sed "s|$HOME|\~|" | $zlua_fzf --query "$query" | sed 's/^[0-9,.]* *//')
|
||||
local selected=$(_zlua -l "${COMP_WORDS[@]:1}" | sed "s|$HOME|\~|" | $zlua_fzf | sed 's/^[0-9,.]* *//')
|
||||
if [ -n "$selected" ]; then
|
||||
COMPREPLY=( "$selected" )
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user