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

put $fish_key_bindings inside quotes #39

Merged
merged 1 commit into from
Sep 26, 2020
Merged

Conversation

uiae
Copy link
Contributor

@uiae uiae commented Sep 26, 2020

This commit fixes startup error messages of fzf.fish in case
$fish_key_bindings is not set.
If $fish_key_bindings is not set to a value, fzf.fish would generate the
following error messages on startup:
[: Missing argument at index 2

~/.config/fish/conf.d/fzf.fish (line 12):
if [ $fish_key_bindings = 'fish_vi_key_bindings' ]
^
from sourcing file ~/.config/fish/conf.d/fzf.fish
called on line 294 of file /usr/share/fish/config.fish
from sourcing file /usr/share/fish/config.fish
called during startup

This commit fixes startup error messages of fzf.fish in case
$fish_key_bindings is not set.
If $fish_key_bindings is not set to a value, fzf.fish would generate the
following error messages on startup:
[: Missing argument at index 2

~/.config/fish/conf.d/fzf.fish (line 12):
    if [ $fish_key_bindings = 'fish_vi_key_bindings' ]
       ^
from sourcing file ~/.config/fish/conf.d/fzf.fish
	called on line 294 of file /usr/share/fish/config.fish
from sourcing file /usr/share/fish/config.fish
	called during startup
@PatrickF1
Copy link
Owner

PatrickF1 commented Sep 26, 2020

Hi @ uiae, change looks good, but I'm curious--why does your fish environment not have a fish_key_bindings variable set? Anyway, thank you so much for opening up this PR and fixing a bug!

@PatrickF1 PatrickF1 merged commit 7b8ca00 into PatrickF1:main Sep 26, 2020
@uiae
Copy link
Contributor Author

uiae commented Sep 30, 2020

Hi patrickf3139, thank you for merging the PR!

You are right, $fish_key_bindings should be set in normal setups of fish.

I stumbled upon this incident while running fish for the first time on a new machine. I migrated all plugins (including fzf) and config.fish to the new machine but not ~/.config/fish/fish_variables.

$fish_key_bindings is set inside ~/.config/fish/fish_variables. If this file does not exist, fish will create it and set $fish_key_bindings to 'fish_default_key_bindings'. Fish will do this after fzf.fish is loaded. Therefore, fzf.fish is loaded before $fish_key_bindings is set, which generates the above-mentioned error message. All consecutive startups of fish shell and fzf.fish are be fine as ~/.config/fish/fish_variables now exists and $fish_key_bindings is set.

So steps to reproduce are:

  • delete ~/.config/fish/fish_variables
  • close all running fish shells
  • open a fish shell

@PatrickF1
Copy link
Owner

Ah that makes sense. Good fix! Even if no one ever deletes that file, I think it makes sense to quote the variable anyway! Thank you uiae.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants