From 793784c08778e8b3fb9d8a2a5621bd968db1dfbe Mon Sep 17 00:00:00 2001 From: "T. Jameson Little" Date: Fri, 30 Jan 2015 22:01:40 -0700 Subject: [PATCH] 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 --- share/functions/__fish_config_interactive.fish | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index 4bd04b62f..ea71a72a5 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -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