command-not-found.plugin.zsh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Uses the command-not-found package zsh support
  2. # as seen in https://www.porcheron.info/command-not-found-for-zsh/
  3. # this is installed in Ubuntu
  4. [[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found
  5. # Arch Linux command-not-found support, you must have package pkgfile installed
  6. # https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook
  7. [[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
  8. # Fedora command-not-found support
  9. if [ -f /usr/libexec/pk-command-not-found ]; then
  10. command_not_found_handler () {
  11. runcnf=1
  12. retval=127
  13. [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0
  14. [ ! -x /usr/libexec/packagekitd ] && runcnf=0
  15. if [ $runcnf -eq 1 ]
  16. then
  17. /usr/libexec/pk-command-not-found $@
  18. retval=$?
  19. fi
  20. return $retval
  21. }
  22. fi
  23. # OSX command-not-found support
  24. # https://github.com/Homebrew/homebrew-command-not-found
  25. if [[ -s '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' ]]; then
  26. source '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh'
  27. fi
  28. # NixOS command-not-found support
  29. if [ -x /run/current-system/sw/bin/command-not-found ]; then
  30. command_not_found_handler () {
  31. /run/current-system/sw/bin/command-not-found $@
  32. }
  33. fi