diff options
author | 2012-12-11 16:00:49 -0800 | |
---|---|---|
committer | 2012-12-11 16:00:49 -0800 | |
commit | 978066a6de537f4920fcd97a85f18c6bd0164783 (patch) | |
tree | 6c4a334a196419b8428bd68f49bd31e47ebe9324 | |
parent | 2628da4a594212156e9d26fb1c07097d4c5bb7fb (diff) |
Attempt to delay looking up command-not-found until the first not-found command to speed up startup
-rw-r--r-- | share/functions/__fish_config_interactive.fish | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index b2c56aee..edd8f184 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -221,21 +221,24 @@ function __fish_config_interactive -d "Initializations that should be performed commandline -f repaint end - # If the ubuntu command-not-found package can be found, add a handler for it - - # First check in /usr/lib, this is where modern Ubuntus place this command - if test -f /usr/lib/command-not-found - function fish_command_not_found_handler --on-event fish_command_not_found - /usr/lib/command-not-found $argv - end - else - # Ubuntu Feisty places this command in the regular path instead - if which command-not-found > /dev/null 2> /dev/null + # The first time a command is not found, look for command-not-found + # This is not cheap so we try to avoid doing it during startup + 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 + + # First check in /usr/lib, this is where modern Ubuntus place this command + if test -f /usr/lib/command-not-found function fish_command_not_found_handler --on-event fish_command_not_found - command-not-found $argv + /usr/lib/command-not-found $argv + end + else + # Ubuntu Feisty places this command in the regular path instead + if type -p command-not-found > /dev/null 2> /dev/null + function fish_command_not_found_handler --on-event fish_command_not_found + command-not-found $argv + end end end end - end - |