doing 2.0.18 → 2.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/Gemfile.lock +15 -5
- data/README.md +1 -1
- data/bin/doing +2 -18
- data/doing.gemspec +5 -4
- data/doing.rdoc +2 -2
- data/generate_completions.sh +3 -3
- data/lib/doing/cli_status.rb +6 -2
- data/lib/doing/completion/bash_completion.rb +185 -0
- data/lib/doing/completion/fish_completion.rb +175 -0
- data/lib/doing/completion/string.rb +17 -0
- data/lib/doing/completion/zsh_completion.rb +140 -0
- data/lib/doing/completion.rb +39 -0
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid.rb +18 -6
- data/lib/doing.rb +1 -1
- data/lib/helpers/fzf/.goreleaser.yml +119 -0
- data/lib/helpers/fzf/.rubocop.yml +28 -0
- data/lib/helpers/fzf/ADVANCED.md +565 -0
- data/lib/helpers/fzf/BUILD.md +49 -0
- data/lib/helpers/fzf/CHANGELOG.md +1193 -0
- data/lib/helpers/fzf/Dockerfile +11 -0
- data/lib/helpers/fzf/LICENSE +21 -0
- data/lib/helpers/fzf/Makefile +166 -0
- data/lib/helpers/fzf/README-VIM.md +486 -0
- data/lib/helpers/fzf/README.md +712 -0
- data/lib/helpers/fzf/bin/fzf-tmux +233 -0
- data/lib/helpers/fzf/doc/fzf.txt +512 -0
- data/lib/helpers/fzf/go.mod +17 -0
- data/lib/helpers/fzf/go.sum +31 -0
- data/lib/helpers/fzf/install +382 -0
- data/lib/helpers/fzf/install.ps1 +65 -0
- data/lib/helpers/fzf/main.go +14 -0
- data/lib/helpers/fzf/man/man1/fzf-tmux.1 +68 -0
- data/lib/helpers/fzf/man/man1/fzf.1 +1001 -0
- data/lib/helpers/fzf/plugin/fzf.vim +1048 -0
- data/lib/helpers/fzf/shell/completion.bash +381 -0
- data/lib/helpers/fzf/shell/completion.zsh +329 -0
- data/lib/helpers/fzf/shell/key-bindings.bash +96 -0
- data/lib/helpers/fzf/shell/key-bindings.fish +172 -0
- data/lib/helpers/fzf/shell/key-bindings.zsh +114 -0
- data/lib/helpers/fzf/src/LICENSE +21 -0
- data/lib/helpers/fzf/src/algo/algo.go +884 -0
- data/lib/helpers/fzf/src/algo/algo_test.go +197 -0
- data/lib/helpers/fzf/src/algo/normalize.go +492 -0
- data/lib/helpers/fzf/src/ansi.go +409 -0
- data/lib/helpers/fzf/src/ansi_test.go +427 -0
- data/lib/helpers/fzf/src/cache.go +81 -0
- data/lib/helpers/fzf/src/cache_test.go +39 -0
- data/lib/helpers/fzf/src/chunklist.go +89 -0
- data/lib/helpers/fzf/src/chunklist_test.go +80 -0
- data/lib/helpers/fzf/src/constants.go +85 -0
- data/lib/helpers/fzf/src/core.go +351 -0
- data/lib/helpers/fzf/src/history.go +96 -0
- data/lib/helpers/fzf/src/history_test.go +68 -0
- data/lib/helpers/fzf/src/item.go +44 -0
- data/lib/helpers/fzf/src/item_test.go +23 -0
- data/lib/helpers/fzf/src/matcher.go +235 -0
- data/lib/helpers/fzf/src/merger.go +120 -0
- data/lib/helpers/fzf/src/merger_test.go +88 -0
- data/lib/helpers/fzf/src/options.go +1691 -0
- data/lib/helpers/fzf/src/options_test.go +457 -0
- data/lib/helpers/fzf/src/pattern.go +425 -0
- data/lib/helpers/fzf/src/pattern_test.go +209 -0
- data/lib/helpers/fzf/src/protector/protector.go +8 -0
- data/lib/helpers/fzf/src/protector/protector_openbsd.go +10 -0
- data/lib/helpers/fzf/src/reader.go +201 -0
- data/lib/helpers/fzf/src/reader_test.go +63 -0
- data/lib/helpers/fzf/src/result.go +243 -0
- data/lib/helpers/fzf/src/result_others.go +16 -0
- data/lib/helpers/fzf/src/result_test.go +159 -0
- data/lib/helpers/fzf/src/result_x86.go +16 -0
- data/lib/helpers/fzf/src/terminal.go +2832 -0
- data/lib/helpers/fzf/src/terminal_test.go +638 -0
- data/lib/helpers/fzf/src/terminal_unix.go +26 -0
- data/lib/helpers/fzf/src/terminal_windows.go +45 -0
- data/lib/helpers/fzf/src/tokenizer.go +253 -0
- data/lib/helpers/fzf/src/tokenizer_test.go +112 -0
- data/lib/helpers/fzf/src/tui/dummy.go +46 -0
- data/lib/helpers/fzf/src/tui/light.go +987 -0
- data/lib/helpers/fzf/src/tui/light_unix.go +110 -0
- data/lib/helpers/fzf/src/tui/light_windows.go +145 -0
- data/lib/helpers/fzf/src/tui/tcell.go +721 -0
- data/lib/helpers/fzf/src/tui/tcell_test.go +392 -0
- data/lib/helpers/fzf/src/tui/ttyname_unix.go +47 -0
- data/lib/helpers/fzf/src/tui/ttyname_windows.go +14 -0
- data/lib/helpers/fzf/src/tui/tui.go +625 -0
- data/lib/helpers/fzf/src/tui/tui_test.go +20 -0
- data/lib/helpers/fzf/src/util/atomicbool.go +34 -0
- data/lib/helpers/fzf/src/util/atomicbool_test.go +17 -0
- data/lib/helpers/fzf/src/util/chars.go +198 -0
- data/lib/helpers/fzf/src/util/chars_test.go +46 -0
- data/lib/helpers/fzf/src/util/eventbox.go +96 -0
- data/lib/helpers/fzf/src/util/eventbox_test.go +61 -0
- data/lib/helpers/fzf/src/util/slab.go +12 -0
- data/lib/helpers/fzf/src/util/util.go +138 -0
- data/lib/helpers/fzf/src/util/util_test.go +40 -0
- data/lib/helpers/fzf/src/util/util_unix.go +47 -0
- data/lib/helpers/fzf/src/util/util_windows.go +83 -0
- data/lib/helpers/fzf/test/fzf.vader +175 -0
- data/lib/helpers/fzf/test/test_go.rb +2626 -0
- data/lib/helpers/fzf/uninstall +117 -0
- data/scripts/generate_bash_completions.rb +6 -12
- data/scripts/generate_fish_completions.rb +7 -16
- data/scripts/generate_zsh_completions.rb +6 -15
- metadata +144 -9
@@ -0,0 +1,712 @@
|
|
1
|
+
<img src="https://raw.githubusercontent.com/junegunn/i/master/fzf.png" height="170" alt="fzf - a command-line fuzzy finder"> [![github-actions](https://github.com/junegunn/fzf/workflows/Test%20fzf%20on%20Linux/badge.svg)](https://github.com/junegunn/fzf/actions)
|
2
|
+
===
|
3
|
+
|
4
|
+
fzf is a general-purpose command-line fuzzy finder.
|
5
|
+
|
6
|
+
<img src="https://raw.githubusercontent.com/junegunn/i/master/fzf-preview.png" width=640>
|
7
|
+
|
8
|
+
It's an interactive Unix filter for command-line that can be used with any
|
9
|
+
list; files, command history, processes, hostnames, bookmarks, git commits,
|
10
|
+
etc.
|
11
|
+
|
12
|
+
Pros
|
13
|
+
----
|
14
|
+
|
15
|
+
- Portable, no dependencies
|
16
|
+
- Blazingly fast
|
17
|
+
- The most comprehensive feature set
|
18
|
+
- Flexible layout
|
19
|
+
- Batteries included
|
20
|
+
- Vim/Neovim plugin, key bindings, and fuzzy auto-completion
|
21
|
+
|
22
|
+
Table of Contents
|
23
|
+
-----------------
|
24
|
+
|
25
|
+
<!-- vim-markdown-toc GFM -->
|
26
|
+
|
27
|
+
* [Installation](#installation)
|
28
|
+
* [Using Homebrew](#using-homebrew)
|
29
|
+
* [Using git](#using-git)
|
30
|
+
* [Using Linux package managers](#using-linux-package-managers)
|
31
|
+
* [Windows](#windows)
|
32
|
+
* [As Vim plugin](#as-vim-plugin)
|
33
|
+
* [Upgrading fzf](#upgrading-fzf)
|
34
|
+
* [Building fzf](#building-fzf)
|
35
|
+
* [Usage](#usage)
|
36
|
+
* [Using the finder](#using-the-finder)
|
37
|
+
* [Layout](#layout)
|
38
|
+
* [Search syntax](#search-syntax)
|
39
|
+
* [Environment variables](#environment-variables)
|
40
|
+
* [Options](#options)
|
41
|
+
* [Demo](#demo)
|
42
|
+
* [Examples](#examples)
|
43
|
+
* [`fzf-tmux` script](#fzf-tmux-script)
|
44
|
+
* [Key bindings for command-line](#key-bindings-for-command-line)
|
45
|
+
* [Fuzzy completion for bash and zsh](#fuzzy-completion-for-bash-and-zsh)
|
46
|
+
* [Files and directories](#files-and-directories)
|
47
|
+
* [Process IDs](#process-ids)
|
48
|
+
* [Host names](#host-names)
|
49
|
+
* [Environment variables / Aliases](#environment-variables--aliases)
|
50
|
+
* [Settings](#settings)
|
51
|
+
* [Supported commands](#supported-commands)
|
52
|
+
* [Custom fuzzy completion](#custom-fuzzy-completion)
|
53
|
+
* [Vim plugin](#vim-plugin)
|
54
|
+
* [Advanced topics](#advanced-topics)
|
55
|
+
* [Performance](#performance)
|
56
|
+
* [Executing external programs](#executing-external-programs)
|
57
|
+
* [Reloading the candidate list](#reloading-the-candidate-list)
|
58
|
+
* [1. Update the list of processes by pressing CTRL-R](#1-update-the-list-of-processes-by-pressing-ctrl-r)
|
59
|
+
* [2. Switch between sources by pressing CTRL-D or CTRL-F](#2-switch-between-sources-by-pressing-ctrl-d-or-ctrl-f)
|
60
|
+
* [3. Interactive ripgrep integration](#3-interactive-ripgrep-integration)
|
61
|
+
* [Preview window](#preview-window)
|
62
|
+
* [Tips](#tips)
|
63
|
+
* [Respecting `.gitignore`](#respecting-gitignore)
|
64
|
+
* [Fish shell](#fish-shell)
|
65
|
+
* [Related projects](#related-projects)
|
66
|
+
* [License](#license)
|
67
|
+
|
68
|
+
<!-- vim-markdown-toc -->
|
69
|
+
|
70
|
+
Installation
|
71
|
+
------------
|
72
|
+
|
73
|
+
fzf project consists of the following components:
|
74
|
+
|
75
|
+
- `fzf` executable
|
76
|
+
- `fzf-tmux` script for launching fzf in a tmux pane
|
77
|
+
- Shell extensions
|
78
|
+
- Key bindings (`CTRL-T`, `CTRL-R`, and `ALT-C`) (bash, zsh, fish)
|
79
|
+
- Fuzzy auto-completion (bash, zsh)
|
80
|
+
- Vim/Neovim plugin
|
81
|
+
|
82
|
+
You can [download fzf executable][bin] alone if you don't need the extra
|
83
|
+
stuff.
|
84
|
+
|
85
|
+
[bin]: https://github.com/junegunn/fzf/releases
|
86
|
+
|
87
|
+
### Using Homebrew
|
88
|
+
|
89
|
+
You can use [Homebrew](http://brew.sh/) (on macOS or Linux)
|
90
|
+
to install fzf.
|
91
|
+
|
92
|
+
```sh
|
93
|
+
brew install fzf
|
94
|
+
|
95
|
+
# To install useful key bindings and fuzzy completion:
|
96
|
+
$(brew --prefix)/opt/fzf/install
|
97
|
+
```
|
98
|
+
|
99
|
+
fzf is also available [via MacPorts][portfile]: `sudo port install fzf`
|
100
|
+
|
101
|
+
[portfile]: https://github.com/macports/macports-ports/blob/master/sysutils/fzf/Portfile
|
102
|
+
|
103
|
+
### Using git
|
104
|
+
|
105
|
+
Alternatively, you can "git clone" this repository to any directory and run
|
106
|
+
[install](https://github.com/junegunn/fzf/blob/master/install) script.
|
107
|
+
|
108
|
+
```sh
|
109
|
+
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
|
110
|
+
~/.fzf/install
|
111
|
+
```
|
112
|
+
|
113
|
+
### Using Linux package managers
|
114
|
+
|
115
|
+
| Package Manager | Linux Distribution | Command |
|
116
|
+
| --- | --- | --- |
|
117
|
+
| APK | Alpine Linux | `sudo apk add fzf` |
|
118
|
+
| APT | Debian 9+/Ubuntu 19.10+ | `sudo apt-get install fzf` |
|
119
|
+
| Conda | | `conda install -c conda-forge fzf` |
|
120
|
+
| DNF | Fedora | `sudo dnf install fzf` |
|
121
|
+
| Nix | NixOS, etc. | `nix-env -iA nixpkgs.fzf` |
|
122
|
+
| Pacman | Arch Linux | `sudo pacman -S fzf` |
|
123
|
+
| pkg | FreeBSD | `pkg install fzf` |
|
124
|
+
| pkgin | NetBSD | `pkgin install fzf` |
|
125
|
+
| pkg_add | OpenBSD | `pkg_add fzf` |
|
126
|
+
| XBPS | Void Linux | `sudo xbps-install -S fzf` |
|
127
|
+
| Zypper | openSUSE | `sudo zypper install fzf` |
|
128
|
+
|
129
|
+
> :warning: **Key bindings (CTRL-T / CTRL-R / ALT-C) and fuzzy auto-completion
|
130
|
+
> may not be enabled by default.**
|
131
|
+
>
|
132
|
+
> Refer to the package documentation for more information. (e.g. `apt-cache show fzf`)
|
133
|
+
|
134
|
+
[![Packaging status](https://repology.org/badge/vertical-allrepos/fzf.svg)](https://repology.org/project/fzf/versions)
|
135
|
+
|
136
|
+
### Windows
|
137
|
+
|
138
|
+
Pre-built binaries for Windows can be downloaded [here][bin]. fzf is also
|
139
|
+
available via [Chocolatey][choco] and [Scoop][scoop]:
|
140
|
+
|
141
|
+
| Package manager | Command |
|
142
|
+
| --- | --- |
|
143
|
+
| Chocolatey | `choco install fzf` |
|
144
|
+
| Scoop | `scoop install fzf` |
|
145
|
+
|
146
|
+
[choco]: https://chocolatey.org/packages/fzf
|
147
|
+
[scoop]: https://github.com/ScoopInstaller/Main/blob/master/bucket/fzf.json
|
148
|
+
|
149
|
+
Known issues and limitations on Windows can be found on [the wiki
|
150
|
+
page][windows-wiki].
|
151
|
+
|
152
|
+
[windows-wiki]: https://github.com/junegunn/fzf/wiki/Windows
|
153
|
+
|
154
|
+
### As Vim plugin
|
155
|
+
|
156
|
+
If you use
|
157
|
+
[vim-plug](https://github.com/junegunn/vim-plug), add this line to your Vim
|
158
|
+
configuration file:
|
159
|
+
|
160
|
+
```vim
|
161
|
+
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
162
|
+
```
|
163
|
+
|
164
|
+
`fzf#install()` makes sure that you have the latest binary, but it's optional,
|
165
|
+
so you can omit it if you use a plugin manager that doesn't support hooks.
|
166
|
+
|
167
|
+
For more installation options, see [README-VIM.md](README-VIM.md).
|
168
|
+
|
169
|
+
Upgrading fzf
|
170
|
+
-------------
|
171
|
+
|
172
|
+
fzf is being actively developed, and you might want to upgrade it once in a
|
173
|
+
while. Please follow the instruction below depending on the installation
|
174
|
+
method used.
|
175
|
+
|
176
|
+
- git: `cd ~/.fzf && git pull && ./install`
|
177
|
+
- brew: `brew update; brew upgrade fzf`
|
178
|
+
- macports: `sudo port upgrade fzf`
|
179
|
+
- chocolatey: `choco upgrade fzf`
|
180
|
+
- vim-plug: `:PlugUpdate fzf`
|
181
|
+
|
182
|
+
Building fzf
|
183
|
+
------------
|
184
|
+
|
185
|
+
See [BUILD.md](BUILD.md).
|
186
|
+
|
187
|
+
Usage
|
188
|
+
-----
|
189
|
+
|
190
|
+
fzf will launch interactive finder, read the list from STDIN, and write the
|
191
|
+
selected item to STDOUT.
|
192
|
+
|
193
|
+
```sh
|
194
|
+
find * -type f | fzf > selected
|
195
|
+
```
|
196
|
+
|
197
|
+
Without STDIN pipe, fzf will use find command to fetch the list of
|
198
|
+
files excluding hidden ones. (You can override the default command with
|
199
|
+
`FZF_DEFAULT_COMMAND`)
|
200
|
+
|
201
|
+
```sh
|
202
|
+
vim $(fzf)
|
203
|
+
```
|
204
|
+
|
205
|
+
#### Using the finder
|
206
|
+
|
207
|
+
- `CTRL-K` / `CTRL-J` (or `CTRL-P` / `CTRL-N`) to move cursor up and down
|
208
|
+
- `Enter` key to select the item, `CTRL-C` / `CTRL-G` / `ESC` to exit
|
209
|
+
- On multi-select mode (`-m`), `TAB` and `Shift-TAB` to mark multiple items
|
210
|
+
- Emacs style key bindings
|
211
|
+
- Mouse: scroll, click, double-click; shift-click and shift-scroll on
|
212
|
+
multi-select mode
|
213
|
+
|
214
|
+
#### Layout
|
215
|
+
|
216
|
+
fzf by default starts in fullscreen mode, but you can make it start below the
|
217
|
+
cursor with `--height` option.
|
218
|
+
|
219
|
+
```sh
|
220
|
+
vim $(fzf --height 40%)
|
221
|
+
```
|
222
|
+
|
223
|
+
Also, check out `--reverse` and `--layout` options if you prefer
|
224
|
+
"top-down" layout instead of the default "bottom-up" layout.
|
225
|
+
|
226
|
+
```sh
|
227
|
+
vim $(fzf --height 40% --reverse)
|
228
|
+
```
|
229
|
+
|
230
|
+
You can add these options to `$FZF_DEFAULT_OPTS` so that they're applied by
|
231
|
+
default. For example,
|
232
|
+
|
233
|
+
```sh
|
234
|
+
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
|
235
|
+
```
|
236
|
+
|
237
|
+
#### Search syntax
|
238
|
+
|
239
|
+
Unless otherwise specified, fzf starts in "extended-search mode" where you can
|
240
|
+
type in multiple search terms delimited by spaces. e.g. `^music .mp3$ sbtrkt
|
241
|
+
!fire`
|
242
|
+
|
243
|
+
| Token | Match type | Description |
|
244
|
+
| --------- | -------------------------- | ------------------------------------ |
|
245
|
+
| `sbtrkt` | fuzzy-match | Items that match `sbtrkt` |
|
246
|
+
| `'wild` | exact-match (quoted) | Items that include `wild` |
|
247
|
+
| `^music` | prefix-exact-match | Items that start with `music` |
|
248
|
+
| `.mp3$` | suffix-exact-match | Items that end with `.mp3` |
|
249
|
+
| `!fire` | inverse-exact-match | Items that do not include `fire` |
|
250
|
+
| `!^music` | inverse-prefix-exact-match | Items that do not start with `music` |
|
251
|
+
| `!.mp3$` | inverse-suffix-exact-match | Items that do not end with `.mp3` |
|
252
|
+
|
253
|
+
If you don't prefer fuzzy matching and do not wish to "quote" every word,
|
254
|
+
start fzf with `-e` or `--exact` option. Note that when `--exact` is set,
|
255
|
+
`'`-prefix "unquotes" the term.
|
256
|
+
|
257
|
+
A single bar character term acts as an OR operator. For example, the following
|
258
|
+
query matches entries that start with `core` and end with either `go`, `rb`,
|
259
|
+
or `py`.
|
260
|
+
|
261
|
+
```
|
262
|
+
^core go$ | rb$ | py$
|
263
|
+
```
|
264
|
+
|
265
|
+
#### Environment variables
|
266
|
+
|
267
|
+
- `FZF_DEFAULT_COMMAND`
|
268
|
+
- Default command to use when input is tty
|
269
|
+
- e.g. `export FZF_DEFAULT_COMMAND='fd --type f'`
|
270
|
+
- > :warning: This variable is not used by shell extensions due to the
|
271
|
+
> slight difference in requirements.
|
272
|
+
>
|
273
|
+
> (e.g. `CTRL-T` runs `$FZF_CTRL_T_COMMAND` instead, `vim **<tab>` runs
|
274
|
+
> `_fzf_compgen_path()`, and `cd **<tab>` runs `_fzf_compgen_dir()`)
|
275
|
+
>
|
276
|
+
> The available options are described later in this document.
|
277
|
+
- `FZF_DEFAULT_OPTS`
|
278
|
+
- Default options
|
279
|
+
- e.g. `export FZF_DEFAULT_OPTS="--layout=reverse --inline-info"`
|
280
|
+
|
281
|
+
#### Options
|
282
|
+
|
283
|
+
See the man page (`man fzf`) for the full list of options.
|
284
|
+
|
285
|
+
#### Demo
|
286
|
+
If you learn by watching videos, check out this screencast by [@samoshkin](https://github.com/samoshkin) to explore `fzf` features.
|
287
|
+
|
288
|
+
<a title="fzf - command-line fuzzy finder" href="https://www.youtube.com/watch?v=qgG5Jhi_Els">
|
289
|
+
<img src="https://i.imgur.com/vtG8olE.png" width="640">
|
290
|
+
</a>
|
291
|
+
|
292
|
+
Examples
|
293
|
+
--------
|
294
|
+
|
295
|
+
* [Wiki page of examples](https://github.com/junegunn/fzf/wiki/examples)
|
296
|
+
* *Disclaimer: The examples on this page are maintained by the community
|
297
|
+
and are not thoroughly tested*
|
298
|
+
* [Advanced fzf examples](https://github.com/junegunn/fzf/blob/master/ADVANCED.md)
|
299
|
+
|
300
|
+
`fzf-tmux` script
|
301
|
+
-----------------
|
302
|
+
|
303
|
+
[fzf-tmux](bin/fzf-tmux) is a bash script that opens fzf in a tmux pane.
|
304
|
+
|
305
|
+
```sh
|
306
|
+
# usage: fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS]
|
307
|
+
|
308
|
+
# See available options
|
309
|
+
fzf-tmux --help
|
310
|
+
|
311
|
+
# select git branches in horizontal split below (15 lines)
|
312
|
+
git branch | fzf-tmux -d 15
|
313
|
+
|
314
|
+
# select multiple words in vertical split on the left (20% of screen width)
|
315
|
+
cat /usr/share/dict/words | fzf-tmux -l 20% --multi --reverse
|
316
|
+
```
|
317
|
+
|
318
|
+
It will still work even when you're not on tmux, silently ignoring `-[pudlr]`
|
319
|
+
options, so you can invariably use `fzf-tmux` in your scripts.
|
320
|
+
|
321
|
+
Alternatively, you can use `--height HEIGHT[%]` option not to start fzf in
|
322
|
+
fullscreen mode.
|
323
|
+
|
324
|
+
```sh
|
325
|
+
fzf --height 40%
|
326
|
+
```
|
327
|
+
|
328
|
+
Key bindings for command-line
|
329
|
+
-----------------------------
|
330
|
+
|
331
|
+
The install script will setup the following key bindings for bash, zsh, and
|
332
|
+
fish.
|
333
|
+
|
334
|
+
- `CTRL-T` - Paste the selected files and directories onto the command-line
|
335
|
+
- Set `FZF_CTRL_T_COMMAND` to override the default command
|
336
|
+
- Set `FZF_CTRL_T_OPTS` to pass additional options
|
337
|
+
- `CTRL-R` - Paste the selected command from history onto the command-line
|
338
|
+
- If you want to see the commands in chronological order, press `CTRL-R`
|
339
|
+
again which toggles sorting by relevance
|
340
|
+
- Set `FZF_CTRL_R_OPTS` to pass additional options
|
341
|
+
- `ALT-C` - cd into the selected directory
|
342
|
+
- Set `FZF_ALT_C_COMMAND` to override the default command
|
343
|
+
- Set `FZF_ALT_C_OPTS` to pass additional options
|
344
|
+
|
345
|
+
If you're on a tmux session, you can start fzf in a tmux split-pane or in
|
346
|
+
a tmux popup window by setting `FZF_TMUX_OPTS` (e.g. `-d 40%`).
|
347
|
+
See `fzf-tmux --help` for available options.
|
348
|
+
|
349
|
+
More tips can be found on [the wiki page](https://github.com/junegunn/fzf/wiki/Configuring-shell-key-bindings).
|
350
|
+
|
351
|
+
Fuzzy completion for bash and zsh
|
352
|
+
---------------------------------
|
353
|
+
|
354
|
+
#### Files and directories
|
355
|
+
|
356
|
+
Fuzzy completion for files and directories can be triggered if the word before
|
357
|
+
the cursor ends with the trigger sequence, which is by default `**`.
|
358
|
+
|
359
|
+
- `COMMAND [DIRECTORY/][FUZZY_PATTERN]**<TAB>`
|
360
|
+
|
361
|
+
```sh
|
362
|
+
# Files under the current directory
|
363
|
+
# - You can select multiple items with TAB key
|
364
|
+
vim **<TAB>
|
365
|
+
|
366
|
+
# Files under parent directory
|
367
|
+
vim ../**<TAB>
|
368
|
+
|
369
|
+
# Files under parent directory that match `fzf`
|
370
|
+
vim ../fzf**<TAB>
|
371
|
+
|
372
|
+
# Files under your home directory
|
373
|
+
vim ~/**<TAB>
|
374
|
+
|
375
|
+
|
376
|
+
# Directories under current directory (single-selection)
|
377
|
+
cd **<TAB>
|
378
|
+
|
379
|
+
# Directories under ~/github that match `fzf`
|
380
|
+
cd ~/github/fzf**<TAB>
|
381
|
+
```
|
382
|
+
|
383
|
+
#### Process IDs
|
384
|
+
|
385
|
+
Fuzzy completion for PIDs is provided for kill command. In this case,
|
386
|
+
there is no trigger sequence; just press the tab key after the kill command.
|
387
|
+
|
388
|
+
```sh
|
389
|
+
# Can select multiple processes with <TAB> or <Shift-TAB> keys
|
390
|
+
kill -9 <TAB>
|
391
|
+
```
|
392
|
+
|
393
|
+
#### Host names
|
394
|
+
|
395
|
+
For ssh and telnet commands, fuzzy completion for hostnames is provided. The
|
396
|
+
names are extracted from /etc/hosts and ~/.ssh/config.
|
397
|
+
|
398
|
+
```sh
|
399
|
+
ssh **<TAB>
|
400
|
+
telnet **<TAB>
|
401
|
+
```
|
402
|
+
|
403
|
+
#### Environment variables / Aliases
|
404
|
+
|
405
|
+
```sh
|
406
|
+
unset **<TAB>
|
407
|
+
export **<TAB>
|
408
|
+
unalias **<TAB>
|
409
|
+
```
|
410
|
+
|
411
|
+
#### Settings
|
412
|
+
|
413
|
+
```sh
|
414
|
+
# Use ~~ as the trigger sequence instead of the default **
|
415
|
+
export FZF_COMPLETION_TRIGGER='~~'
|
416
|
+
|
417
|
+
# Options to fzf command
|
418
|
+
export FZF_COMPLETION_OPTS='--border --info=inline'
|
419
|
+
|
420
|
+
# Use fd (https://github.com/sharkdp/fd) instead of the default find
|
421
|
+
# command for listing path candidates.
|
422
|
+
# - The first argument to the function ($1) is the base path to start traversal
|
423
|
+
# - See the source code (completion.{bash,zsh}) for the details.
|
424
|
+
_fzf_compgen_path() {
|
425
|
+
fd --hidden --follow --exclude ".git" . "$1"
|
426
|
+
}
|
427
|
+
|
428
|
+
# Use fd to generate the list for directory completion
|
429
|
+
_fzf_compgen_dir() {
|
430
|
+
fd --type d --hidden --follow --exclude ".git" . "$1"
|
431
|
+
}
|
432
|
+
|
433
|
+
# (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function
|
434
|
+
# - The first argument to the function is the name of the command.
|
435
|
+
# - You should make sure to pass the rest of the arguments to fzf.
|
436
|
+
_fzf_comprun() {
|
437
|
+
local command=$1
|
438
|
+
shift
|
439
|
+
|
440
|
+
case "$command" in
|
441
|
+
cd) fzf "$@" --preview 'tree -C {} | head -200' ;;
|
442
|
+
export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;;
|
443
|
+
ssh) fzf "$@" --preview 'dig {}' ;;
|
444
|
+
*) fzf "$@" ;;
|
445
|
+
esac
|
446
|
+
}
|
447
|
+
```
|
448
|
+
|
449
|
+
#### Supported commands
|
450
|
+
|
451
|
+
On bash, fuzzy completion is enabled only for a predefined set of commands
|
452
|
+
(`complete | grep _fzf` to see the list). But you can enable it for other
|
453
|
+
commands as well by using `_fzf_setup_completion` helper function.
|
454
|
+
|
455
|
+
```sh
|
456
|
+
# usage: _fzf_setup_completion path|dir|var|alias|host COMMANDS...
|
457
|
+
_fzf_setup_completion path ag git kubectl
|
458
|
+
_fzf_setup_completion dir tree
|
459
|
+
```
|
460
|
+
|
461
|
+
#### Custom fuzzy completion
|
462
|
+
|
463
|
+
_**(Custom completion API is experimental and subject to change)**_
|
464
|
+
|
465
|
+
For a command named _"COMMAND"_, define `_fzf_complete_COMMAND` function using
|
466
|
+
`_fzf_complete` helper.
|
467
|
+
|
468
|
+
```sh
|
469
|
+
# Custom fuzzy completion for "doge" command
|
470
|
+
# e.g. doge **<TAB>
|
471
|
+
_fzf_complete_doge() {
|
472
|
+
_fzf_complete --multi --reverse --prompt="doge> " -- "$@" < <(
|
473
|
+
echo very
|
474
|
+
echo wow
|
475
|
+
echo such
|
476
|
+
echo doge
|
477
|
+
)
|
478
|
+
}
|
479
|
+
```
|
480
|
+
|
481
|
+
- The arguments before `--` are the options to fzf.
|
482
|
+
- After `--`, simply pass the original completion arguments unchanged (`"$@"`).
|
483
|
+
- Then, write a set of commands that generates the completion candidates and
|
484
|
+
feed its output to the function using process substitution (`< <(...)`).
|
485
|
+
|
486
|
+
zsh will automatically pick up the function using the naming convention but in
|
487
|
+
bash you have to manually associate the function with the command using the
|
488
|
+
`complete` command.
|
489
|
+
|
490
|
+
```sh
|
491
|
+
[ -n "$BASH" ] && complete -F _fzf_complete_doge -o default -o bashdefault doge
|
492
|
+
```
|
493
|
+
|
494
|
+
If you need to post-process the output from fzf, define
|
495
|
+
`_fzf_complete_COMMAND_post` as follows.
|
496
|
+
|
497
|
+
```sh
|
498
|
+
_fzf_complete_foo() {
|
499
|
+
_fzf_complete --multi --reverse --header-lines=3 -- "$@" < <(
|
500
|
+
ls -al
|
501
|
+
)
|
502
|
+
}
|
503
|
+
|
504
|
+
_fzf_complete_foo_post() {
|
505
|
+
awk '{print $NF}'
|
506
|
+
}
|
507
|
+
|
508
|
+
[ -n "$BASH" ] && complete -F _fzf_complete_foo -o default -o bashdefault foo
|
509
|
+
```
|
510
|
+
|
511
|
+
Vim plugin
|
512
|
+
----------
|
513
|
+
|
514
|
+
See [README-VIM.md](README-VIM.md).
|
515
|
+
|
516
|
+
Advanced topics
|
517
|
+
---------------
|
518
|
+
|
519
|
+
### Performance
|
520
|
+
|
521
|
+
fzf is fast and is [getting even faster][perf]. Performance should not be
|
522
|
+
a problem in most use cases. However, you might want to be aware of the
|
523
|
+
options that affect performance.
|
524
|
+
|
525
|
+
- `--ansi` tells fzf to extract and parse ANSI color codes in the input, and it
|
526
|
+
makes the initial scanning slower. So it's not recommended that you add it
|
527
|
+
to your `$FZF_DEFAULT_OPTS`.
|
528
|
+
- `--nth` makes fzf slower because it has to tokenize each line.
|
529
|
+
- `--with-nth` makes fzf slower as fzf has to tokenize and reassemble each
|
530
|
+
line.
|
531
|
+
- If you absolutely need better performance, you can consider using
|
532
|
+
`--algo=v1` (the default being `v2`) to make fzf use a faster greedy
|
533
|
+
algorithm. However, this algorithm is not guaranteed to find the optimal
|
534
|
+
ordering of the matches and is not recommended.
|
535
|
+
|
536
|
+
[perf]: https://junegunn.kr/images/fzf-0.17.0.png
|
537
|
+
|
538
|
+
### Executing external programs
|
539
|
+
|
540
|
+
You can set up key bindings for starting external processes without leaving
|
541
|
+
fzf (`execute`, `execute-silent`).
|
542
|
+
|
543
|
+
```bash
|
544
|
+
# Press F1 to open the file with less without leaving fzf
|
545
|
+
# Press CTRL-Y to copy the line to clipboard and aborts fzf (requires pbcopy)
|
546
|
+
fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort'
|
547
|
+
```
|
548
|
+
|
549
|
+
See *KEY BINDINGS* section of the man page for details.
|
550
|
+
|
551
|
+
### Reloading the candidate list
|
552
|
+
|
553
|
+
By binding `reload` action to a key or an event, you can make fzf dynamically
|
554
|
+
reload the candidate list. See https://github.com/junegunn/fzf/issues/1750 for
|
555
|
+
more details.
|
556
|
+
|
557
|
+
#### 1. Update the list of processes by pressing CTRL-R
|
558
|
+
|
559
|
+
```sh
|
560
|
+
FZF_DEFAULT_COMMAND='ps -ef' \
|
561
|
+
fzf --bind 'ctrl-r:reload($FZF_DEFAULT_COMMAND)' \
|
562
|
+
--header 'Press CTRL-R to reload' --header-lines=1 \
|
563
|
+
--height=50% --layout=reverse
|
564
|
+
```
|
565
|
+
|
566
|
+
#### 2. Switch between sources by pressing CTRL-D or CTRL-F
|
567
|
+
|
568
|
+
```sh
|
569
|
+
FZF_DEFAULT_COMMAND='find . -type f' \
|
570
|
+
fzf --bind 'ctrl-d:reload(find . -type d),ctrl-f:reload($FZF_DEFAULT_COMMAND)' \
|
571
|
+
--height=50% --layout=reverse
|
572
|
+
```
|
573
|
+
|
574
|
+
#### 3. Interactive ripgrep integration
|
575
|
+
|
576
|
+
The following example uses fzf as the selector interface for ripgrep. We bound
|
577
|
+
`reload` action to `change` event, so every time you type on fzf, the ripgrep
|
578
|
+
process will restart with the updated query string denoted by the placeholder
|
579
|
+
expression `{q}`. Also, note that we used `--disabled` option so that fzf
|
580
|
+
doesn't perform any secondary filtering.
|
581
|
+
|
582
|
+
```sh
|
583
|
+
INITIAL_QUERY=""
|
584
|
+
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
|
585
|
+
FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \
|
586
|
+
fzf --bind "change:reload:$RG_PREFIX {q} || true" \
|
587
|
+
--ansi --disabled --query "$INITIAL_QUERY" \
|
588
|
+
--height=50% --layout=reverse
|
589
|
+
```
|
590
|
+
|
591
|
+
If ripgrep doesn't find any matches, it will exit with a non-zero exit status,
|
592
|
+
and fzf will warn you about it. To suppress the warning message, we added
|
593
|
+
`|| true` to the command, so that it always exits with 0.
|
594
|
+
|
595
|
+
### Preview window
|
596
|
+
|
597
|
+
When the `--preview` option is set, fzf automatically starts an external process
|
598
|
+
with the current line as the argument and shows the result in the split window.
|
599
|
+
Your `$SHELL` is used to execute the command with `$SHELL -c COMMAND`.
|
600
|
+
The window can be scrolled using the mouse or custom key bindings.
|
601
|
+
|
602
|
+
```bash
|
603
|
+
# {} is replaced with the single-quoted string of the focused line
|
604
|
+
fzf --preview 'cat {}'
|
605
|
+
```
|
606
|
+
|
607
|
+
Preview window supports ANSI colors, so you can use any program that
|
608
|
+
syntax-highlights the content of a file, such as
|
609
|
+
[Bat](https://github.com/sharkdp/bat) or
|
610
|
+
[Highlight](http://www.andre-simon.de/doku/highlight/en/highlight.php):
|
611
|
+
|
612
|
+
```bash
|
613
|
+
fzf --preview 'bat --style=numbers --color=always --line-range :500 {}'
|
614
|
+
```
|
615
|
+
|
616
|
+
You can customize the size, position, and border of the preview window using
|
617
|
+
`--preview-window` option, and the foreground and background color of it with
|
618
|
+
`--color` option. For example,
|
619
|
+
|
620
|
+
```bash
|
621
|
+
fzf --height 40% --layout reverse --info inline --border \
|
622
|
+
--preview 'file {}' --preview-window up,1,border-horizontal \
|
623
|
+
--color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,preview-bg:#223344,border:#778899'
|
624
|
+
```
|
625
|
+
|
626
|
+
See the man page (`man fzf`) for the full list of options.
|
627
|
+
|
628
|
+
For more advanced examples, see [Key bindings for git with fzf][fzf-git]
|
629
|
+
([code](https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236)).
|
630
|
+
|
631
|
+
[fzf-git]: https://junegunn.kr/2016/07/fzf-git/
|
632
|
+
|
633
|
+
----
|
634
|
+
|
635
|
+
Since fzf is a general-purpose text filter rather than a file finder, **it is
|
636
|
+
not a good idea to add `--preview` option to your `$FZF_DEFAULT_OPTS`**.
|
637
|
+
|
638
|
+
```sh
|
639
|
+
# *********************
|
640
|
+
# ** DO NOT DO THIS! **
|
641
|
+
# *********************
|
642
|
+
export FZF_DEFAULT_OPTS='--preview "bat --style=numbers --color=always --line-range :500 {}"'
|
643
|
+
|
644
|
+
# bat doesn't work with any input other than the list of files
|
645
|
+
ps -ef | fzf
|
646
|
+
seq 100 | fzf
|
647
|
+
history | fzf
|
648
|
+
```
|
649
|
+
|
650
|
+
Tips
|
651
|
+
----
|
652
|
+
|
653
|
+
#### Respecting `.gitignore`
|
654
|
+
|
655
|
+
You can use [fd](https://github.com/sharkdp/fd),
|
656
|
+
[ripgrep](https://github.com/BurntSushi/ripgrep), or [the silver
|
657
|
+
searcher](https://github.com/ggreer/the_silver_searcher) instead of the
|
658
|
+
default find command to traverse the file system while respecting
|
659
|
+
`.gitignore`.
|
660
|
+
|
661
|
+
```sh
|
662
|
+
# Feed the output of fd into fzf
|
663
|
+
fd --type f | fzf
|
664
|
+
|
665
|
+
# Setting fd as the default source for fzf
|
666
|
+
export FZF_DEFAULT_COMMAND='fd --type f'
|
667
|
+
|
668
|
+
# Now fzf (w/o pipe) will use fd instead of find
|
669
|
+
fzf
|
670
|
+
|
671
|
+
# To apply the command to CTRL-T as well
|
672
|
+
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
673
|
+
```
|
674
|
+
|
675
|
+
If you want the command to follow symbolic links and don't want it to exclude
|
676
|
+
hidden files, use the following command:
|
677
|
+
|
678
|
+
```sh
|
679
|
+
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
|
680
|
+
```
|
681
|
+
|
682
|
+
#### Fish shell
|
683
|
+
|
684
|
+
`CTRL-T` key binding of fish, unlike those of bash and zsh, will use the last
|
685
|
+
token on the command-line as the root directory for the recursive search. For
|
686
|
+
instance, hitting `CTRL-T` at the end of the following command-line
|
687
|
+
|
688
|
+
```sh
|
689
|
+
ls /var/
|
690
|
+
```
|
691
|
+
|
692
|
+
will list all files and directories under `/var/`.
|
693
|
+
|
694
|
+
When using a custom `FZF_CTRL_T_COMMAND`, use the unexpanded `$dir` variable to
|
695
|
+
make use of this feature. `$dir` defaults to `.` when the last token is not a
|
696
|
+
valid directory. Example:
|
697
|
+
|
698
|
+
```sh
|
699
|
+
set -g FZF_CTRL_T_COMMAND "command find -L \$dir -type f 2> /dev/null | sed '1d; s#^\./##'"
|
700
|
+
```
|
701
|
+
|
702
|
+
Related projects
|
703
|
+
----------------
|
704
|
+
|
705
|
+
https://github.com/junegunn/fzf/wiki/Related-projects
|
706
|
+
|
707
|
+
[License](LICENSE)
|
708
|
+
------------------
|
709
|
+
|
710
|
+
The MIT License (MIT)
|
711
|
+
|
712
|
+
Copyright (c) 2013-2021 Junegunn Choi
|