mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-11 05:31:14 -03:00
We no longer emit the "fish_command_not_found" event ourselves, so the event handlers are only useful to users who 1. run "emit fish_command_not_found" 2. copy the definition of "fish_command_not_found" to their config and run that with fish < 3.2. Probably no one does 1; there are no matches in https://github.com/search?utf8=%E2%9C%93&q=%22emit+fish_command_not_found%22+language%3Afish&type=code Reason 2 is less relevant after 5 years. For additional evidence, none of our specializations ("/usr/libexec/pk-command-not-found" etc.) react to the event, and no one has ever complained. Stop registering any fish_command_not_found as event handler, for consistency and simplicity. While at it, remove the documentation on how to make it work for version < 3.2.
53 lines
1.3 KiB
ReStructuredText
53 lines
1.3 KiB
ReStructuredText
fish_command_not_found - what to do when a command wasn't found
|
|
===============================================================
|
|
|
|
Synopsis
|
|
--------
|
|
|
|
.. synopsis::
|
|
|
|
function fish_command_not_found
|
|
...
|
|
end
|
|
|
|
|
|
Description
|
|
-----------
|
|
|
|
When fish tries to execute a command and can't find it, it invokes this function.
|
|
|
|
It can print a message to tell you about it, and it often also checks for a missing package that would include the command.
|
|
|
|
Fish ships multiple handlers for various operating systems and chooses from them when this function is loaded,
|
|
or you can define your own.
|
|
|
|
It receives the full commandline as one argument per token, so $argv[1] contains the missing command.
|
|
|
|
When you leave ``fish_command_not_found`` undefined (e.g. by adding an empty function file) or explicitly call ``__fish_default_command_not_found_handler``, fish will just print a simple error.
|
|
|
|
Example
|
|
-------
|
|
|
|
A simple handler:
|
|
|
|
::
|
|
|
|
function fish_command_not_found
|
|
echo Did not find command $argv[1]
|
|
end
|
|
|
|
> flounder
|
|
Did not find command flounder
|
|
|
|
Or the handler for OpenSUSE's command-not-found::
|
|
|
|
function fish_command_not_found
|
|
/usr/bin/command-not-found $argv[1]
|
|
end
|
|
|
|
Or the simple default handler::
|
|
|
|
function fish_command_not_found
|
|
__fish_default_command_not_found_handler $argv
|
|
end
|