From 7cab7c158d6c9a6f439736421867d953ce8cea1d Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Fri, 16 Apr 2021 19:53:25 +0100 Subject: [PATCH] feat(zsh): override command not found to add command not found link When you run a shell command that is not found this will print out a link to https://command-not-found.com to give more info on the command and good docs on how to install the package that the command came from. This can be built on to do other things like git suggestions on common commands that are incorrect --- .../oh-my-zsh/custom/command-not-found.zsh | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 site-modules/core/files/oh-my-zsh/custom/command-not-found.zsh diff --git a/site-modules/core/files/oh-my-zsh/custom/command-not-found.zsh b/site-modules/core/files/oh-my-zsh/custom/command-not-found.zsh new file mode 100644 index 0000000..104c1a3 --- /dev/null +++ b/site-modules/core/files/oh-my-zsh/custom/command-not-found.zsh @@ -0,0 +1,20 @@ +# +# Custom command not found hander to add links to https://command-not-found.com +# this gives a nice way to display how to install al command +# + +[[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found +[[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh + +command_not_found_handler () { + [[ "$1" == '_'* ]] && return 1 + + echo " +Command '$1' is not found. + +You can find out how to install it by visiting + +https://command-not-found.com/$1 +" + return 127 +}