Add command-not-found handler for Arch Linux

- checks for `pkgfile`, which is an optional (but official)
  package used for searching for packages given a file
This commit is contained in:
T. Jameson Little 2015-01-30 22:01:40 -07:00
parent df6f1e8f62
commit 793784c087

View file

@ -234,6 +234,18 @@ function __fish_config_interactive -d "Initializations that should be performed
function __fish_command_not_found_handler --on-event fish_command_not_found
command-not-found -- $argv
end
# pkgfile is an optional, but official, package on Arch Linux
# it ships with example handlers for bash and zsh, so we'll follow that format
else if type -p -q pkgfile
function __fish_command_not_found_handler --on-event fish_command_not_found
set -l __packages (pkgfile --binaries --verbose -- $argv ^/dev/null)
if test $status -eq 0
printf "%s may be found in the following packages:\n" "$argv"
printf " %s\n" $__packages
else
__fish_default_command_not_found_handler $argv
end
end
# Use standard fish command not found handler otherwise
else
function __fish_command_not_found_handler --on-event fish_command_not_found