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
Provenance
- Commit
e1c8f19- Tree
1b14ece- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
5e302c7
1 file changed+84 added−0 removed
modified:README.md+84 added
44 unmodified lines45 * [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 lines389 ----------390 391 See [README-VIM.md](README-VIM.md).392 393+Advanced topics394+---------------395+396+### Performance397+398+fzf is fast, and is [getting even faster][perf]. Performance should not be399+a problem in most use cases. However, you might want to be aware of the400+options that affect the performance.401+402+- `--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.412+413+[perf]: https://junegunn.kr/images/fzf-0.16.10.png414+415+### Executing external programs416+417+You can set up key bindings for starting external process in the foreground418+(`execute`) or in the background (`execute-silent`).419+420+```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)423+fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort'424+```425+426+See *KEY BINDINGS* section of the man page for details.427+428+### Preview window429+430+When `--preview` option is set, fzf automatically starts external process with431+the current line as the argument and shows the result in the split window.432+433+```sh434+# {} is replaced to the single-quoted string of the focused line435+fzf --preview 'cat {}'436+```437+438+Since preview window is updated only after the process is complete, it's439+important that the command finishes quickly.440+441+```sh442+# Use head instead of cat so that the command doesn't take too long to finish443+fzf --preview 'head -100 {}'444+```445+446+Preview window supports ANSI colors, so you can use programs that447+syntax-highlights the content of a file.448+449+- Highlight: http://www.andre-simon.de/doku/highlight/en/highlight.php450+- CodeRay: http://coderay.rubychan.de/451+- Rouge: https://github.com/jneen/rouge452+453+```sh454+# Try highlight, coderay, rougify in turn, then fall back to cat455+fzf --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+```462+463+You can customize the size and position of the preview window using464+`--preview-window` option. For example,465+466+```sh467+fzf --height 40% --reverse --preview 'file {}' --preview-window down:1468+```469+470+For more advanced examples, see [Key bindings for git with fzf][fzf-git].471+472+[fzf-git]: https://junegunn.kr/2016/07/fzf-git/473+474 Tips475 ----476 477 #### Respecting `.gitignore`, `.hgignore`, and `svn:ignore`79 unmodified lines