mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 12:15:08 +00:00
Immediately define command-not-found handler
This skips the weird dance where we'd define a simple handler and then later overwrite with a fancier one, once the first event came in. It turns out that isn't necessary, as it doesn't actually improve startup speed because the checks needed to define fancier handlers are fast. In case we are non-interactive, still define the simple handler, and keep the default handler for users to switch to.
This commit is contained in:
parent
b7fb11cb7f
commit
1a12071a48
2 changed files with 14 additions and 25 deletions
|
@ -19,10 +19,9 @@ end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Hook up the default as the principal command_not_found handler
|
# Hook up the default as the principal command_not_found handler
|
||||||
# for starting up since finding and executing a real one is not cheap
|
# in case we are not interactive
|
||||||
# This will be erased in __fish_command_not_found_setup once we're interactive
|
|
||||||
#
|
#
|
||||||
function __fish_startup_command_not_found_handler --on-event fish_command_not_found
|
status -i; or function __fish_command_not_found_handler --on-event fish_command_not_found
|
||||||
__fish_default_command_not_found_handler $argv
|
__fish_default_command_not_found_handler $argv
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -171,23 +171,13 @@ function __fish_config_interactive -d "Initializations that should be performed
|
||||||
__update_vte_cwd # Run once because we might have already inherited a PWD from an old tab
|
__update_vte_cwd # Run once because we might have already inherited a PWD from an old tab
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove the startup command_not_found handler since we're done with it
|
### Command-not-found handlers
|
||||||
functions -e __fish_startup_command_not_found_handler
|
# This can be overridden by defining a new __fish_command_not_found_handler function
|
||||||
|
if not type -q __fish_command_not_found_handler
|
||||||
# Now install our fancy variant
|
|
||||||
function __fish_command_not_found_setup --on-event fish_command_not_found
|
|
||||||
# Remove fish_command_not_found_setup so we only execute this once
|
|
||||||
functions --erase __fish_command_not_found_setup
|
|
||||||
|
|
||||||
# If the user defined a handler, it takes precedence
|
|
||||||
# It does not need to be executed because it's been defined before the event
|
|
||||||
if type -q __fish_command_not_found_handler
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
# 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
|
||||||
# and expects first argument to be a command and second database
|
# and expects first argument to be a command and second database
|
||||||
# also check if there is command-not-found command.
|
# also check if there is command-not-found command.
|
||||||
if begin; test -f /etc/SuSE-release; and type -q -p command-not-found; end
|
if test -f /etc/SuSE-release; and type -q -p 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]
|
||||||
end
|
end
|
||||||
|
@ -229,8 +219,8 @@ function __fish_config_interactive -d "Initializations that should be performed
|
||||||
__fish_default_command_not_found_handler $argv[1]
|
__fish_default_command_not_found_handler $argv[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
__fish_command_not_found_handler $argv
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if test $TERM = "linux" # A linux in-kernel VT with 8 colors and 256/512 glyphs
|
if test $TERM = "linux" # A linux in-kernel VT with 8 colors and 256/512 glyphs
|
||||||
# In a VT we have
|
# In a VT we have
|
||||||
# black (invisible)
|
# black (invisible)
|
||||||
|
|
Loading…
Reference in a new issue