Add --fish

pull/3675/head
Junegunn Choi 3 months ago
parent c37b9071ea
commit a1dfe0455e
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -104,7 +104,7 @@ fzf project consists of the following components:
- `fzf` executable
- `fzf-tmux` script for launching fzf in a tmux pane
- Shell extensions
- Shell integration
- Key bindings (`CTRL-T`, `CTRL-R`, and `ALT-C`) (bash, zsh, fish)
- Fuzzy auto-completion (bash, zsh)
- Vim/Neovim plugin
@ -121,11 +121,24 @@ to install fzf.
```sh
brew install fzf
# To install useful key bindings and fuzzy completion:
$(brew --prefix)/opt/fzf/install
```
This only installs the binary. To set up shell integration, add the following
line to your shell configuration file.
* bash
```sh
source <(fzf --bash)
```
* zsh
```sh
source <(zsh --zsh)
```
* fish
```fish
fzf --fish | source
```
fzf is also available [via MacPorts][portfile]: `sudo port install fzf`
[portfile]: https://github.com/macports/macports-ports/blob/master/sysutils/fzf/Portfile
@ -319,7 +332,7 @@ or `py`.
- `FZF_DEFAULT_COMMAND`
- Default command to use when input is tty
- e.g. `export FZF_DEFAULT_COMMAND='fd --type f'`
- > :warning: This variable is not used by shell extensions due to the
- > :warning: This variable is not used by shell integration due to the
> slight difference in requirements.
>
> (e.g. `CTRL-T` runs `$FZF_CTRL_T_COMMAND` instead, `vim **<tab>` runs

@ -23,6 +23,9 @@ var zshKeyBindings []byte
//go:embed shell/completion.zsh
var zshCompletion []byte
//go:embed shell/key-bindings.fish
var fishKeyBindings []byte
func main() {
protector.Protect()
options := fzf.ParseOptions()
@ -36,5 +39,10 @@ func main() {
fmt.Println(string(zshCompletion))
return
}
if options.Fish {
fmt.Println(string(fishKeyBindings))
fmt.Println("fzf_key_bindings")
return
}
fzf.Run(options, version, revision)
}

@ -857,19 +857,24 @@ Display version information and exit
.TP
Note that most options have the opposite versions with \fB--no-\fR prefix.
.SS Shell extension
.SS Shell integration
.TP
.B "--bash"
Print script to set up Bash shell extension
Print script to set up Bash shell integration
e.g. \fBsource <(fzf --bash)\fR
.TP
.B "--zsh"
Print script to set up Zsh shell extension
Print script to set up Zsh shell integration
e.g. \fBsource <(fzf --zsh)\fR
.TP
.B "--fish"
Print script to set up Fish shell integration
e.g. \fBfzf --fish | source\fR
.SH ENVIRONMENT VARIABLES
.TP

@ -124,9 +124,10 @@ const usage = `usage: fzf [options]
(To allow remote process execution, use --listen-unsafe)
--version Display version information and exit
Shell extension
--bash Print script to set up Bash shell extension
--zsh Print script to set up Zsh shell extension
Shell integration
--bash Print script to set up Bash shell integration
--zsh Print script to set up Zsh shell integration
--fish Print script to set up Fish shell integration
Environment variables
FZF_DEFAULT_COMMAND Default command to use when input is tty
@ -282,6 +283,7 @@ func firstLine(s string) string {
type Options struct {
Bash bool
Zsh bool
Fish bool
Fuzzy bool
FuzzyAlgo algo.Algo
Scheme string
@ -359,6 +361,7 @@ func defaultOptions() *Options {
return &Options{
Bash: false,
Zsh: false,
Fish: false,
Fuzzy: true,
FuzzyAlgo: algo.FuzzyMatchV2,
Scheme: "default",
@ -1612,13 +1615,18 @@ func parseOptions(opts *Options, allArgs []string) {
switch arg {
case "--bash":
opts.Bash = true
if opts.Zsh {
errorExit("cannot specify both --bash and --zsh")
if opts.Zsh || opts.Fish {
errorExit("cannot specify --bash with --zsh or --fish")
}
case "--zsh":
opts.Zsh = true
if opts.Bash {
errorExit("cannot specify both --bash and --zsh")
if opts.Bash || opts.Fish {
errorExit("cannot specify --zsh with --bash or --fish")
}
case "--fish":
opts.Fish = true
if opts.Bash || opts.Zsh {
errorExit("cannot specify --fish with --bash or --zsh")
}
case "-h", "--help":
help(exitOk)

Loading…
Cancel
Save