Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add $FZF_DEFAULT_OPTS_FILE #3618

Merged
merged 2 commits into from Feb 29, 2024
Merged

Add $FZF_DEFAULT_OPTS_FILE #3618

merged 2 commits into from Feb 29, 2024

Conversation

junegunn
Copy link
Owner

@junegunn junegunn commented Feb 8, 2024

For those who prefer to manage default options in a file. If the file is not found, fzf will exit with an error.

We're not setting a default value for it because:

  1. it's hard to find a default value that can be universally agreed upon
  2. to avoid fzf having to check for the existence of the file even when it's not used

Comparison to the alternatives

1. Reading the file from the shell configuration file

export FZF_DEFAULT_OPTS=$(cat ~/.fzfrc)

Compared to the above, with FZF_DEFAULT_OPTS_FILE,

  • You don't have to reload your shell configuration file after editing the file
  • An external script can modify the configuration file in the background

2. Wrapper script or function

fzf() {
  FZF_DEFAULT_OPTS=$(cat ~/.fzfrc) command fzf "$@"
}

This gives the same benefits of FZF_DEFAULT_OPTS_FILE listed above. But you have to manage the function or script yourself.

For those who prefer to manage default options in a file.
If the file is not found, fzf will exit with an error.

We're not setting a default value for it because:

1. it's hard to find a default value that can be universally agreed upon
2. to avoid fzf having to check for the existence of the file even when it's not used
@junegunn junegunn merged commit 1833670 into master Feb 29, 2024
7 checks passed
@junegunn junegunn deleted the devel branch February 29, 2024 03:08
PatrickF1 added a commit to PatrickF1/dotfiles that referenced this pull request Apr 7, 2024
Newly implemented in junegunn/fzf#3618

Reduces work keeping fzf default opts consistent across shells

Allows changing opts without restarting or reloading shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant