Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fzf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
fzf
Commits
e1c8f19e
Unverified
Commit
e1c8f19e
authored
7 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Update README: Advanced topics
parent
5e302c70
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+84
-0
84 additions, 0 deletions
README.md
with
84 additions
and
0 deletions
README.md
+
84
−
0
View file @
e1c8f19e
...
...
@@ -46,6 +46,9 @@ Table of Contents
*
[
Settings
](
#settings
)
*
[
Supported commands
](
#supported-commands
)
*
[
Vim plugin
](
#vim-plugin
)
*
[
Advanced topics
](
#advanced-topics
)
*
[
Performance
](
#performance
)
*
[
Preview window
](
#preview-window
)
*
[
Tips
](
#tips
)
*
[
Respecting .gitignore, <code>.hgignore</code>, and <code>svn:ignore</code>
](
#respecting-gitignore-hgignore-and-svnignore
)
*
[
git ls-tree for fast traversal
](
#git-ls-tree-for-fast-traversal
)
...
...
@@ -387,6 +390,87 @@ Vim plugin
See
[
README-VIM.md
](
README-VIM.md
)
.
Advanced topics
---------------
### Performance
fzf is fast, and is
[
getting even faster
][
perf
]
. Performance should not be
a problem in most use cases. However, you might want to be aware of the
options that affect the performance.
-
`--ansi`
tells fzf to extract and parse ANSI color codes in the input and it
makes the initial scanning slower. So it's not recommended that you add it
to your
`$FZF_DEFAULT_OPTS`
.
-
`--nth`
makes fzf slower as fzf has to tokenize each line.
-
`--with-nth`
makes fzf slower as fzf has to tokenize and reassemble each
line.
-
If you absolutely need better performance, you can consider using
`--algo=v1`
(the default being
`v2`
) to make fzf use faster greedy
algorithm. However, this algorithm is not guaranteed to find the optimal
ordering of the matches and is not recommended.
[
perf
]:
https://junegunn.kr/images/fzf-0.16.10.png
### Executing external programs
You can set up key bindings for starting external process in the foreground
(
`execute`
) or in the background (
`execute-silent`
).
```
sh
# Press F1 to open the file with less without exiting fzf
# Press CTRL-Y to copy the line to clipboard and aborts fzf (requires pbcopy)
fzf
--bind
'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort'
```
See
*KEY BINDINGS*
section of the man page for details.
### Preview window
When
`--preview`
option is set, fzf automatically starts external process with
the current line as the argument and shows the result in the split window.
```
sh
# {} is replaced to the single-quoted string of the focused line
fzf
--preview
'cat {}'
```
Since preview window is updated only after the process is complete, it's
important that the command finishes quickly.
```
sh
# Use head instead of cat so that the command doesn't take too long to finish
fzf
--preview
'head -100 {}'
```
Preview window supports ANSI colors, so you can use programs that
syntax-highlights the content of a file.
-
Highlight: http://www.andre-simon.de/doku/highlight/en/highlight.php
-
CodeRay: http://coderay.rubychan.de/
-
Rouge: https://github.com/jneen/rouge
```
sh
# Try highlight, coderay, rougify in turn, then fall back to cat
fzf
--preview
'[[ $(file --mime {}) =~ binary ]] &&
echo {} is a binary file ||
(highlight -O ansi -l {} ||
coderay {} ||
rougify {} ||
cat {}) 2> /dev/null | head -500'
```
You can customize the size and position of the preview window using
`--preview-window`
option. For example,
```
sh
fzf
--height
40%
--reverse
--preview
'file {}'
--preview-window
down:1
```
For more advanced examples, see
[
Key bindings for git with fzf
][
fzf-git
]
.
[
fzf-git
]:
https://junegunn.kr/2016/07/fzf-git/
Tips
----
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment