:cherry_blossom: A command-line fuzzy finder
--tiebreak=chunk
crashes on inverse match queryPutting it all together..
# With http://metaphorpsum.com/ and https://github.com/busyloop/lolcat
label1=$(curl -s http://metaphorpsum.com/sentences/1 | lolcat -f)
label2=$(curl -s http://metaphorpsum.com/sentences/1 | lolcat -f)
# Using colors from 'cosmic_latte'
# (See https://github.com/junegunn/fzf/blob/master/ADVANCED.md#generating-fzf-color-theme-from-vim-color-schemes)
fzf --border=double \
--border-label="╣ ${label1} ╠" --border-label-pos=-3,bottom \
--color=bg+:#2b3740,bg:#202a31,spinner:#7d9761,hl:#898f9e,fg:#abb0c0,header:#898f9e,info:#459d90 \
--color=pointer:#7d9761,marker:#7d9761,fg+:#abb0c0,prompt:#7d9761,hl+:#7d9761,border:#2b3740,label:#2b3740 \
--preview='lolcat -f {}' --preview-label="┓ ${label2} ┏" \
--preview-window=top,border-bold \
--separator=$(lolcat -f -F 1.4 <<< ╸╸╸╸╸╸╸╸╸╸╸╸╸╸)
start
event that is triggered only once when fzf finder starts. Since fzf consumes the input stream asynchronously, the input list is not available unless you use --sync
.
seq 100 | fzf --multi --sync --bind 'start:last+select-all+preview(echo welcome)'
--border-label
and --border-label-pos
for putting label on the border
# ANSI color codes are supported
# (with https://github.com/busyloop/lolcat)
label=$(curl -s http://metaphorpsum.com/sentences/1 | lolcat -f)
# Border label at the center
fzf --height=10 --border --border-label="╢ $label ╟" --color=label:italic:black
# Left-aligned (positive integer)
fzf --height=10 --border --border-label="╢ $label ╟" --border-label-pos=3 --color=label:italic:black
# Right-aligned (negative integer) on the bottom line (:bottom)
fzf --height=10 --border --border-label="╢ $label ╟" --border-label-pos=-3:bottom --color=label:italic:black
--preview-label
and --preview-label-pos
for the border of the preview window
fzf --preview 'cat {}' --border --preview-label=' Preview ' --preview-label-pos=2
--no-separator
or --separator=''
to hide the separator--separator=╸
--color=separator:...
fzf --separator=╸ --color=separator:green
fzf --separator=$(lolcat -f -F 1.4 <<< ▁▁▂▃▄▅▆▆▅▄▃▂▁▁) --info=inline
--border=bold
and --border=double
along with --preview-window=border-bold
and --preview-window=border-double
--height
. If the --height
value is prefixed
with ~
, fzf will automatically determine the height in the range according
to the input size.
seq 1 | fzf --height ~70% --border --padding 1 --margin 1
seq 10 | fzf --height ~70% --border --padding 1 --margin 1
seq 100 | fzf --height ~70% --border --padding 1 --margin 1
# This is not allowed (top/bottom margin in percent value)
fzf --height ~50% --border --margin 5%,10%
# This is allowed (top/bottom margin in fixed value)
fzf --height ~50% --border --margin 2,10%
# fzf will open immediately
(sleep 2; seq 10) | fzf --height 50%
# fzf will open after 2 seconds
(sleep 2; seq 10) | fzf --height ~50%
(sleep 2; seq 1000) | fzf --height ~50%
--no-clear
is deprecated. Use reload
action instead.--scheme=[default|path|history]
option to choose scoring scheme
default
) is not always giving the optimal resultpath
: Additional bonus point is only given to the the characters after
path separator. You might want to choose this scheme if you have many
files with spaces in their paths.history
: No additional bonus points are given so that we give more
weight to the chronological ordering. This is equivalent to the scoring
scheme before 0.32.0. This also sets --tiebreak=index
.printf "\e[38;5;208mOption 1\e[m\nOption 2" | fzf --ansi
printf "\e[38:5:208mOption 1\e[m\nOption 2" | fzf --ansi
border-{up,down}
as the synonyms for border-{top,bottom}
in
--preview-window
strikethrough
printf "\e[9mdeleted" | fzf --ansi
fzf --color fg+:strikethrough
--tiebreak=chunk
fzf-tmux -p70%
fzf-tmux -p70% --color=border:bright-red
fzf-tmux -p100%,60% --color=border:bright-yellow --border=horizontal --padding 1,5 --margin 1,0
fzf-tmux -p70%,100% --color=border:bright-green --border=vertical
# Key bindings (CTRL-T, CTRL-R, ALT-C) will use these options
export FZF_TMUX_OPTS='-p100%,60% --color=border:green --border=horizontal --padding 1,5 --margin 1,0'
/,:;|
)# foo/bar.sh` is preferred over `foo-bar.sh` on `bar`
fzf --query=bar --height=4 << EOF
foo-bar.sh
foo/bar.sh
EOF
chunk
length
, this scheme works well with tabular input
# length prefers item #1, because the whole line is shorter,
# chunk prefers item #2, because the matched chunk ("foo") is shorter
fzf --height=6 --header-lines=2 --tiebreak=chunk --reverse --query=fo << "EOF"
N | Field1 | Field2 | Field3
- | ------ | ------ | ------
1 | hello | foobar | baz
2 | world | foo | bazbaz
EOF
chunk
is equivalent to
length
. But we're not going to set it as the default because it is
computationally more expensive.# If the width of the preview window is smaller than 50 columns,
# it will be displayed above the search window.
fzf --preview 'cat {}' --preview-window 'right,50%,border-left,<50(up,30%,border-bottom)'
# Or you can just hide it like so
fzf --preview 'cat {}' --preview-window '<50(hidden)'
unicode.IsGraphic
constraint
for --marker
, --pointer
, and --ellipsis
. Allows Nerd Fonts and stuff.
Use at your own risk.kill
completion now requires trigger sequence (**
) for consistency--ellipsis
option. You can take advantage of it to make fzf
effectively search non-visible parts of the item.
# Search against hidden line numbers on the far right
nl /usr/share/dict/words |
awk '{printf "%s%1000s\n", $2, $1}' |
fzf --nth=-1 --no-hscroll --ellipsis='' |
awk '{print $2}'
rebind
action for restoring bindings after unbind
change-preview(...)
action to change the --preview
command
preview(...)
is a one-off action that doesn't change the default
preview commandchange-preview-window(...)
action
|
fzf --preview 'cat {}' --preview-window right,40% \
--bind 'ctrl-/:change-preview-window(right,70%|down,40%,border-top|hidden|)'
--info=inline
--header-first
option to print header before the prompt line
fzf --header $'Welcome to fzf\n▔▔▔▔▔▔▔▔▔▔▔▔▔▔' --reverse --height 30% --border --header-first
--scroll-off=LINES
option (similar to scrolloff
option of Vim)
fzf --scroll-off=5
fzf --scroll-off=999
reload
(#2644)$SHELL
to execute external programs