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

Kartik
  • 1,984
  • 1
  • 19
  • 28

1 Answers1

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
Chris Down
  • 122,090
  • 24
  • 265
  • 262
  • 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 Mar 02 '19 at 03:43