I just learned this trick so I thought I’d share it. When a command is not found in BASH, you usually get something like this:

$ xmp
The program 'xmp' is currently not installed. You can install it by typing:
sudo apt-get install xmp

If there is no exact match, it will attempt to find similar commands:

$ xmmp
No command 'xmmp' found, did you mean:
 Command 'qmmp' from package 'qmmp' (universe)
 Command 'xmp' from package 'xmp' (universe)
xmmp: command not found

However, when we try this in Zsh, we don’t get that fanciness:

% xmp
xmp: command not found

How unhelpful. Luckily, we have a way to fix this. First, make sure you have command-not-found installed:

% sudo apt-get install command-not-found

Next, add this to your ~/.zshrc:

% source /etc/zsh_command_not_found

Restart your terminal, and you should be all set!

% xmp
The program 'xmp' is currently not installed. You can install it by typing:
sudo apt-get install xmp

Much nicer.

About Mark Fischer, Jr.

Mark is a web developer and programmer. He likes reading classic novels, listening to classical music, skiing, and eating donuts.

Filed under linux, tips