3

When I write a command that does not exist in the fish shell (let's say l instead of ls), fish takes some time before responding that the command does not exist.

I don't know if it looks for package to install or something else, but it is a bit annoying and I need to hit Ctrl-C to avoid waiting a few seconds.

Is there a way to disable this "feature", whatever it is?

2
  • 1
    This is probably the command-not-found handler. What is your operating system? Oct 28, 2015 at 17:06
  • GNU/Linux (ArchLinux). I found out that if I enter twice the same wrong command, the second time I wait less time.
    – antoyo
    Oct 28, 2015 at 22:54

3 Answers 3

5

As ridiculous_fish says, this is probably due to the command-not-found handler.

You can try adding this suggestion to your config.fish:

function __fish_default_command_not_found_handler --on-event fish_command_not_found
  functions --erase __fish_command_not_found_setup
  echo "'$argv' not found"
end
5
  • Thanks. With this function, I get the message twice, but I does not solve the issue (it is as slow as before). At first, I thought that it could take some time to look in $PATH, but the syntax highlighting is quick, so I am not sure it could causes this issue. What else could cause this issue?
    – antoyo
    Oct 29, 2015 at 2:24
  • You could run fish under strace and see what it's blocking on.
    – Zanchey
    Oct 29, 2015 at 9:05
  • One noticeable difference when running strace is that I see more select(8, [7], NULL, NULL, {0, 10000}) = 0 (Timeout) when it is slower. What does it mean?
    – antoyo
    Oct 30, 2015 at 14:12
  • Could you open an issue on Github and we can try to get to the bottom of it?
    – Zanchey
    Oct 31, 2015 at 11:53
  • 1
    That was indeed the solution. For some reason, fish did not load it correctly the first time I tried this solution. After a reboot, everything is fine. Thanks.
    – antoyo
    Nov 1, 2015 at 4:46
1

Since the other answer does not work anymore, I found another solution which consists of adding this function in config.fish:

function __fish_command_not_found_handler --on-event fish_command_not_found
    echo "fish: Unknown command '$argv'"
end
0

There is a streamlined, documented and hopefully long-term supported way to override this by declaring custom fish_command_not_found function.

~/.config/fish/functions/fish_command_not_found.fish:

function fish_command_not_found
    echo "fish: Unknown command '$argv'" >&2
end

http://fishshell.com/docs/current/cmds/fish_command_not_found.html

2
  • How is this different from the accepted answer? Jul 7, 2023 at 9:49
  • 1
    @DaniyalAhmadSE, See the linked doc. Using --on-event fish_command_not_found is a legacy approach, and should be replaced with a function with given name going forward. Jul 24, 2023 at 6:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .