/zsh_command_not_found

http://github.com/brinkman83/bashrc · #! · 25 lines · 20 code · 5 blank · 0 comment · 0 complexity · d8030e5bf568d7d6d126f88f70399e52 MD5 · raw file

  1. # (c) Zygmunt Krynicki 2007,
  2. # Licensed under GPL, see COPYING for the whole text
  3. #
  4. # This script will look-up command in the database and suggest
  5. # installation of packages available from the repository
  6. # Pseudo-namespace cnf_
  7. function cnf_preexec() {
  8. typeset -g cnf_command="${1%% *}"
  9. }
  10. function cnf_precmd() {
  11. (($?)) && [ -n "$cnf_command" ] && [ -x /usr/lib/command-not-found ] && {
  12. whence -- "$cnf_command" >& /dev/null ||
  13. /usr/bin/python /usr/lib/command-not-found -- "$cnf_command"
  14. unset cnf_command
  15. }
  16. }
  17. typeset -ga preexec_functions
  18. typeset -ga precmd_functions
  19. preexec_functions+=cnf_preexec
  20. precmd_functions+=cnf_precmd