1 ## Platforms with a built-in command-not-found handler init file
4 # Arch Linux. Must have pkgfile installed: https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found
5 /usr/share/doc/pkgfile/command-not-found.zsh
6 # macOS (M1 and classic Homebrew): https://github.com/Homebrew/homebrew-command-not-found
7 /opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
8 /usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
10 if [[ -r "$file" ]]; then
19 ## Platforms with manual command_not_found_handler() setup
21 # Debian and derivatives: https://launchpad.net/ubuntu/+source/command-not-found
22 if [[ -x /usr/lib/command-not-found || -x /usr/share/command-not-found/command-not-found ]]; then
23 command_not_found_handler() {
24 if [[ -x /usr/lib/command-not-found ]]; then
25 /usr/lib/command-not-found -- "$1"
27 elif [[ -x /usr/share/command-not-found/command-not-found ]]; then
28 /usr/share/command-not-found/command-not-found -- "$1"
31 printf "zsh: command not found: %s\n" "$1" >&2
37 # Fedora: https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound
38 if [[ -x /usr/libexec/pk-command-not-found ]]; then
39 command_not_found_handler() {
40 if [[ -S /var/run/dbus/system_bus_socket && -x /usr/libexec/packagekitd ]]; then
41 /usr/libexec/pk-command-not-found "$@"
45 printf "zsh: command not found: %s\n" "$1" >&2
50 # NixOS: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found
51 if [[ -x /run/current-system/sw/bin/command-not-found ]]; then
52 command_not_found_handler() {
53 /run/current-system/sw/bin/command-not-found "$@"
57 # Termux: https://github.com/termux/command-not-found
58 if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then
59 command_not_found_handler() {
60 /data/data/com.termux/files/usr/libexec/termux/command-not-found "$1"
64 # SUSE and derivates: https://www.unix.com/man-page/suse/1/command-not-found/
65 if [[ -x /usr/bin/command-not-found ]]; then
66 command_not_found_handler() {
67 /usr/bin/command-not-found "$1"