5

In bash, whenever I try to run a command which is not installed, I get a message which tells that the package is not installed and how to install it. This functionality is provided by installing the Debian/Ubuntu package command-not-found. But in zsh, it only gives the message command not found. So how do I install this feature in zsh?

error in zsh

0

1 Answer 1

8

As long as you have the command-not-found package installed, all you should need to do is source the zsh config for that package by adding the following line to your ~/.zshrc, and then opening a new shell (or running . ~/.zshrc in any existing ones):

[[ -r /etc/zsh_command_not_found ]] && . /etc/zsh_command_not_found
1
  • 1
    Unfortunately this removes the 'command not found' message when alternatives aren't found. This seems like a bug. Replacing the command-not-found call with /usr/lib/command-not-found ${1} fixes that problem.
    – naught101
    Commented Mar 2, 2019 at 3:43

Not the answer you're looking for? Browse other questions tagged .