Make fish more resilient to empty key bindings

If fish_key_bindings gets set to empty, fish will become unusable.
In this case reset it to fish_default_key_bindings.
This commit is contained in:
ridiculousfish 2018-04-01 16:11:12 -07:00
parent 222a45f07a
commit ca13e816ce

View file

@ -188,13 +188,14 @@ function __fish_config_interactive -d "Initializations that should be performed
complete -x -p "/etc/init.d/*" -a reload --description 'Reload service configuration' complete -x -p "/etc/init.d/*" -a reload --description 'Reload service configuration'
end end
# Reload key bindings when binding variable change
function __fish_reload_key_bindings -d "Reload key bindings when binding variable change" --on-variable fish_key_bindings
# Make sure some key bindings are set # Make sure some key bindings are set
if not set -q fish_key_bindings if not set -q fish_key_bindings
set -U fish_key_bindings fish_default_key_bindings set -U fish_key_bindings fish_default_key_bindings
end end
# Reload key bindings when binding variable change
function __fish_reload_key_bindings -d "Reload key bindings when binding variable change" --on-variable fish_key_bindings
# Do nothing if the key bindings didn't actually change. # Do nothing if the key bindings didn't actually change.
# This could be because the variable was set to the existing value # This could be because the variable was set to the existing value
# or because it was a local variable. # or because it was a local variable.
@ -297,7 +298,8 @@ function __fish_config_interactive -d "Initializations that should be performed
# First check if we are on OpenSUSE since SUSE's handler has no options # First check if we are on OpenSUSE since SUSE's handler has no options
# but the same name and path as Ubuntu's. # but the same name and path as Ubuntu's.
if contains -- suse $os; or contains -- sles $os if contains -- suse $os
or contains -- sles $os
and type -q command-not-found and type -q command-not-found
function __fish_command_not_found_handler --on-event fish_command_not_found function __fish_command_not_found_handler --on-event fish_command_not_found
/usr/bin/command-not-found $argv[1] /usr/bin/command-not-found $argv[1]