a8afe14b93051178264db802d964c7f31a552e8d

Author
Session小胡 <102411014+SessionHu@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(command-not-found): add alpine support (#13864)

Diff

 1diff --git a/plugins/command-not-found/README.md b/plugins/command-not-found/README.md
 2index 5079b1fb5bca26d179335f2374e81d081e4209d3..81f90adfa34a5e353412ebf5c6b62bd554c70e8b 100644
 3--- a/plugins/command-not-found/README.md
 4+++ b/plugins/command-not-found/README.md
 5@@ -32,5 +32,6 @@ It works out of the box with the command-not-found packages for:
 6 - [SUSE](https://www.unix.com/man-page/suse/1/command-not-found/)
 7 - [Gentoo](https://github.com/AndrewAmmerlaan/command-not-found-gentoo/tree/main)
 8 - [Void Linux](https://codeberg.org/classabbyamp/xbps-command-not-found)
 9+- [Alpine Linux](https://pkgs.alpinelinux.org/package/edge/main/x86_64/command-not-found)
10 
11 You can add support for other platforms by submitting a Pull Request.
12diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh
13index a85dbfdc3736f2f30f9fc4581f56f69e2aa3177c..59a86e7d51b15c833322b5d929dbb082538fa071 100644
14--- a/plugins/command-not-found/command-not-found.plugin.zsh
15+++ b/plugins/command-not-found/command-not-found.plugin.zsh
16@@ -74,3 +74,10 @@ if [[ -x /usr/bin/command-not-found ]]; then
17     /usr/bin/command-not-found "$1"
18   }
19 fi
20+
21+# Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/command-not-found/APKBUILD
22+if [[ -x /usr/libexec/command-not-found ]]; then
23+  command_not_found_handler() {
24+    /usr/libexec/command-not-found "$1"
25+  }
26+fi