-
Notifications
You must be signed in to change notification settings - Fork 141
Effective with fzf
When you input:
z -I vim
History directories matching vim
will be sorted by frecent
and sent to fzf:
The first column is the frecent
of a directory, the higher frecent
comes with the higher rank. It is convenience because the directory you are most likely to choose will be easier to be found.
You can use arrow key UP
/DOWN
(as well as CTRL
+J
/K
) to move around the cursor (red >
symbol) then <ENTER>
to accept or <ESC>
/CTRL+D
to give up.
If you are not satisfied with the result, continue to input some space separated keywords to filter the result:
After input keyword git
, only 6 paths are left. You may want to use cursor to select one, or continue input one more keyword:
Now, you have inputed two keyword git
and sk
, only one path is left. Press enter to select or <Backspace>
to modify your keywords, or <ESC>
to give up.
NOTE: keywords are not required to be in order in fzf, /home/skywind/github/vim
can be matched with git sk
or sk git
. So, when you are using fzf, you can always append a space followed by a new keyword.
Remember to set your $TERM
to xterm-256color
.
If you are not satisfied with the default fzf parameter, you can override them by $_ZL_FZF_FLAG
, which is default to +s -e
. +s
(--no-sort
) will keep the input in default order and -e
will use space to split keywords.
If you wish, you can remove +s
by:
export _ZL_FZF_FLAG="-e"
Set $_ZL_INT_SORT
to 1 to sort directories by alphabet in interactive mode (both -i
and -I
):
export _ZL_INT_SORT=1
Option $_ZL_FZF_HEIGHT
to control --height
parameter in fzf:
# fzf: full screen
export _ZL_FZF_HEIGHT=0
# fzf: 30 lines
export _ZL_FZF_HEIGHT=30
# fzf: 35% of screen height
export _ZL_FZF_HEIGHT="35%"
Define a new zii
shell function to override z -I
:
function zii() {
local $dir="$(z -l "$@"|fzf --nth 2.. --reverse --inline-info --tac +s -e --height 35%)"
[ -n "$dir" ] && cd "$(echo $dir | sed -e 's/^\S*\s*//')"
}
or just ignore the frecent
order:
function zii() {
local $dir="$(z -l -s "$@"|fzf ---reverse -e --height 35%)"
[ -n "$dir" ] && cd "$dir"
}