Skip to content

Commit

Permalink
Add support for FZF_DEFAULT_OPTS_FILE (#319)
Browse files Browse the repository at this point in the history
Don't set default fzf options if FZF_DEFAULT_OPTS_FILE is set. FZF_DEFAULT_OPTS_FILE was added to fzf in version 0.47.0

---------

Co-authored-by: Patrick Fong <patrickf3139@gmail.com>
  • Loading branch information
stdlo and PatrickF1 committed Apr 7, 2024
1 parent dfdf693 commit 8920367
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ Call `fzf_configure_bindings` in your `config.fish` in order to persist your cus

### Change fzf options for all commands

fzf supports global default options via the [FZF_DEFAULT_OPTS](https://github.com/junegunn/fzf#environment-variables) environment variable.

`fzf.fish` sets [a sane `FZF_DEFAULT_OPTS` whenever it executes fzf](functions/_fzf_wrapper.fish). If you export your own `FZF_DEFAULT_OPTS`, then yours will be used instead.
fzf supports global default options via the [FZF_DEFAULT_OPTS and FZF_DEFAULT_OPTS_FILE](https://github.com/junegunn/fzf#environment-variables) environment variables. If neither are set, `fzf.fish` sets its own [default opts whenever it executes fzf](functions/_fzf_wrapper.fish).

### Change fzf options for a specific command

Expand Down
5 changes: 3 additions & 2 deletions functions/_fzf_wrapper.fish
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ function _fzf_wrapper --description "Prepares some environment variables before
# Use --function so that it doesn't clobber SHELL outside this function.
set -f --export SHELL (command --search fish)

# If FZF_DEFAULT_OPTS is not set, then set some sane defaults.
# If neither FZF_DEFAULT_OPTS nor FZF_DEFAULT_OPTS_FILE are set, then set some sane defaults.
# See https://github.com/junegunn/fzf#environment-variables
if not set --query FZF_DEFAULT_OPTS
set --query FZF_DEFAULT_OPTS FZF_DEFAULT_OPTS_FILE
if test $status -eq 2
# cycle allows jumping between the first and last results, making scrolling faster
# layout=reverse lists results top to bottom, mimicking the familiar layouts of git log, history, and env
# border shows where the fzf window begins and ends
Expand Down

0 comments on commit 8920367

Please sign in to comment.