Fzf: Difference between revisions
From wikinotes
(Created page with " fzf serves two primary roles: * a generic fuzzy finder for files/dirs on the CLI * a shell library to extend aliases or methods to use a fuzzy finder I have only barel...") |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
fzf is a tool that lets you fuzzy search lines piped to it on stdin. | |||
fzf | = Documentation = | ||
<blockquote> | |||
{| class="wikitable" | |||
|- | |||
| github || https://github.com/junegunn/fzf | |||
|- | |||
| <code>man fzf</code> || https://man.archlinux.org/man/community/fzf/fzf.1.en | |||
|- | |||
|} | |||
</blockquote><!-- Documentation --> | |||
= Examples = | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
result=$(find . | fzf +m) # interactively choose one result | |||
results=($(find . | fzf -m)) # interactively choose multiple results | |||
find . | fzf -q todo # interactively choose results, filtered in advance to those matching 'todo' | |||
find . | fzf --filter todo # print results fuzzy-matched to 'todo' on stdout | |||
</syntaxhighlight> | |||
</blockquote><!-- Examples --> | |||
= Usage = | |||
<blockquote> | |||
== CLI Arguments == | |||
<blockquote> | |||
=== Search Modes === | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
fzf \ | |||
-q $SEARCH `# search interactively for $SEARCH` \ | |||
-f $SEARCH `# print results for $SEARCH` | |||
`# if neither -q/-f, user types search interactively` | |||
</syntaxhighlight> | |||
</blockquote><!-- Search Modes --> | |||
=== Match Customization === | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
fzf \ | |||
-m `# allow multiple-selections` \ | |||
+m `# disallow multiple-selections` \ | |||
-i `# case insensitive` \ | |||
-e `# exact-matches only (like 'foo)` \ | |||
--tiebreak=length,end `# choose between equally scoring matches` | |||
</syntaxhighlight> | |||
</blockquote><!-- Match Customization --> | |||
=== Query Syntax === | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
foo # fuzzy-matches | |||
'foo # exact-matches (rather than fuzzy) | |||
^foo$ # anchored matches start/end | |||
!foo # results that don't match foo | |||
foo | bar # or | |||
'foo bar # compound matches | |||
</syntaxhighlight> | |||
</blockquote><!-- Query Syntax --> | |||
</blockquote><!-- CLI Arguments --> | |||
== Keybindings == | |||
<blockquote> | |||
Default Keybindings | |||
<syntaxhighlight lang="yaml"> | |||
up/down # go up/down entry | |||
tab # mark entry as selected (when multi-select active) | |||
enter # single-select and exit | |||
# type # search results | |||
</syntaxhighlight> | |||
You can set your own keybindings as well<br> | |||
See '''AVAILABLE ACTIONS''' in [https://man.archlinux.org/man/community/fzf/fzf.1.en man fzf] | |||
<syntaxhighlight lang="bash"> | |||
export FZF_DEFAULT_OPTS='\ | |||
--bind \ | |||
ctrl-a:select-all,\ | |||
ctrl-d:deselect-all' | |||
</syntaxhighlight> | |||
</blockquote><!-- Keybindings --> | |||
</blockquote><!-- Usage --> | |||
= Extensions = | |||
<blockquote> | |||
{| class="wikitable" | |||
|- | |||
| fzf-tab (fzf-on-tabcomplete) || https://github.com/Aloxaf/fzf-tab | |||
|- | |||
|} | |||
</blockquote><!-- Extensions --> | |||
= Configuration = | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
fzf --color=light # change fzf theme to light | |||
</syntaxhighlight> | |||
</blockquote><!-- Configuration --> |
Latest revision as of 22:17, 6 May 2023
fzf is a tool that lets you fuzzy search lines piped to it on stdin.
Documentation
github https://github.com/junegunn/fzf man fzf
https://man.archlinux.org/man/community/fzf/fzf.1.en
Examples
result=$(find . | fzf +m) # interactively choose one result results=($(find . | fzf -m)) # interactively choose multiple results find . | fzf -q todo # interactively choose results, filtered in advance to those matching 'todo' find . | fzf --filter todo # print results fuzzy-matched to 'todo' on stdout
Usage
CLI Arguments
Search Modes
fzf \ -q $SEARCH `# search interactively for $SEARCH` \ -f $SEARCH `# print results for $SEARCH` `# if neither -q/-f, user types search interactively`Match Customization
fzf \ -m `# allow multiple-selections` \ +m `# disallow multiple-selections` \ -i `# case insensitive` \ -e `# exact-matches only (like 'foo)` \ --tiebreak=length,end `# choose between equally scoring matches`Query Syntax
foo # fuzzy-matches 'foo # exact-matches (rather than fuzzy) ^foo$ # anchored matches start/end !foo # results that don't match foo foo | bar # or 'foo bar # compound matchesKeybindings
Default Keybindings
up/down # go up/down entry tab # mark entry as selected (when multi-select active) enter # single-select and exit # type # search resultsYou can set your own keybindings as well
See AVAILABLE ACTIONS in man fzfexport FZF_DEFAULT_OPTS='\ --bind \ ctrl-a:select-all,\ ctrl-d:deselect-all'
Extensions
fzf-tab (fzf-on-tabcomplete) https://github.com/Aloxaf/fzf-tab
Configuration
fzf --color=light # change fzf theme to light