Skip to content
Myr

Update README: Advanced topics

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 5e302c7 · Browse files · 1 file+84 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+84 added−0 removed

  • other:+84 added−0 removed

1 file+84 added−0 removed

modified:README.md+84 added
44 unmodified lines
45 * [Environment variables / Aliases](#environment-variables--aliases)46 * [Settings](#settings)47 * [Supported commands](#supported-commands)48 * [Vim plugin](#vim-plugin)49 * [Advanced topics](#advanced-topics)50 * [Performance](#performance)51 * [Preview window](#preview-window)52 * [Tips](#tips)53 * [Respecting .gitignore, <code>.hgignore</code>, and <code>svn:ignore</code>](#respecting-gitignore-hgignore-and-svnignore)54 * [git ls-tree for fast traversal](#git-ls-tree-for-fast-traversal)55 * [Fish shell](#fish-shell)
333 unmodified lines
389----------390391See [README-VIM.md](README-VIM.md).392393Advanced topics394---------------395396### Performance397398fzf is fast, and is [getting even faster][perf]. Performance should not be399a problem in most use cases. However, you might want to be aware of the400options that affect the performance.401402- `--ansi` tells fzf to extract and parse ANSI color codes in the input and it403 makes the initial scanning slower. So it's not recommended that you add it404 to your `$FZF_DEFAULT_OPTS`.405- `--nth` makes fzf slower as fzf has to tokenize each line.406- `--with-nth` makes fzf slower as fzf has to tokenize and reassemble each407 line.408- If you absolutely need better performance, you can consider using409 `--algo=v1` (the default being `v2`) to make fzf use faster greedy410 algorithm. However, this algorithm is not guaranteed to find the optimal411 ordering of the matches and is not recommended.412413[perf]: https://junegunn.kr/images/fzf-0.16.10.png414415### Executing external programs416417You can set up key bindings for starting external process in the foreground418(`execute`) or in the background (`execute-silent`).419420```sh421# Press F1 to open the file with less without exiting fzf422# Press CTRL-Y to copy the line to clipboard and aborts fzf (requires pbcopy)423fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort'424```425426See *KEY BINDINGS* section of the man page for details.427428### Preview window429430When `--preview` option is set, fzf automatically starts external process with431the current line as the argument and shows the result in the split window.432433```sh434# {} is replaced to the single-quoted string of the focused line435fzf --preview 'cat {}'436```437438Since preview window is updated only after the process is complete, it's439important that the command finishes quickly.440441```sh442# Use head instead of cat so that the command doesn't take too long to finish443fzf --preview 'head -100 {}'444```445446Preview window supports ANSI colors, so you can use programs that447syntax-highlights the content of a file.448449- Highlight: http://www.andre-simon.de/doku/highlight/en/highlight.php450- CodeRay: http://coderay.rubychan.de/451- Rouge: https://github.com/jneen/rouge452453```sh454# Try highlight, coderay, rougify in turn, then fall back to cat455fzf --preview '[[ $(file --mime {}) =~ binary ]] &&456 echo {} is a binary file ||457 (highlight -O ansi -l {} ||458 coderay {} ||459 rougify {} ||460 cat {}) 2> /dev/null | head -500'461```462463You can customize the size and position of the preview window using464`--preview-window` option. For example,465466```sh467fzf --height 40% --reverse --preview 'file {}' --preview-window down:1468```469470For more advanced examples, see [Key bindings for git with fzf][fzf-git].471472[fzf-git]: https://junegunn.kr/2016/07/fzf-git/473474Tips475----476477#### Respecting `.gitignore`, `.hgignore`, and `svn:ignore`
79 unmodified lines