Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In the default configuration of bash in ubuntu, when you type the name of a software which is not installed, bash explains how to install it if the executable if it exists, or how to install an executable with a really close name if it does not exist. For example with emacs (which is not installed on my machine):

$ emacx
No command 'emacx' found, did you mean:
 Command 'emacs' from package 'emacs23-lucid' (universe)
 Command 'emacs' from package 'e3' (universe)
 Command 'emacs' from package 'emacs23-nox' (main)
 Command 'emacs' from package 'emacs24' (main)
 Command 'emacs' from package 'emacs24-nox' (main)
 Command 'emacs' from package 'emacs23' (main)
 Command 'emacs' from package 'jove' (universe)
 Command 'emacs' from package 'emacs24-lucid' (universe)
emacx: command not found
$ emacs
The program 'emacs' can be found in the following packages:
 * emacs23
 * emacs23-nox
 * emacs24
 * emacs24-nox
 * e3
 * emacs23-lucid
 * emacs24-lucid
 * jove
Try: sudo apt-get install <selected package>

With my current configuration of zsh I obtain:

$ emacx
zsh: command not found: emacx
$ emacs
zsh: command not found: emacs

There is also a difference of behavior when making a mistake in the name of an installed software. Say I want to launch gedit instead of kedit. With bash, I obtain:

$ kedit
No command 'kedit' found, did you mean:
 Command 'xedit' from package 'x11-apps' (main)
 Command 'edit' from package 'mime-support' (main)
 Command 'nedit' from package 'nedit' (universe)
 Command 'gedit' from package 'gedit' (main)
 Command 'jedit' from package 'jedit' (universe)
 Command 'medit' from package 'medit' (universe)
 Command 'ledit' from package 'ledit' (main)
kedit: command not found

While with zsh I obtain:

$ kedit
zsh: correct 'kedit' to 'edit' [nyae]?

So, my questions are:

  • Is it possible to have a similar behavior in zsh as with bash when trying to launch an executable not yet installed? If yes, how?
  • Is it possible to display all the possibilities when there is a typing mistake, instead of giving one correction which can be wrong?
share|improve this question

1 Answer 1

up vote 4 down vote accepted

The default zsh configuration for Debian (and probably Ubuntu) just doesn't include support for the command-not-found package per default.

In order to have the same functionality you just have to source /etc/zsh_command_not_found in your ~/.zshrc per default via:

[ -f /etc/zsh_command_not_found ] && . /etc/zsh_command_not_found

This should load and enable the command-not-found functionality in zsh.

share|improve this answer
    
thanks, it is the perfect solution –  rgiot Feb 20 '13 at 17:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.