1

Most Linux operating systems have a package like command-not-found (http://packages.ubuntu.com/utopic/command-not-found), which provides suggestions when a shell command was not found, e.g. because the command was misspelt.

➜ puthon
No command 'puthon' found, did you mean:
 Command 'python' from package 'python-minimal' (main)
 Command 'python' from package 'python3' (main)

Is there similar functionality for OS X, e.g. through Homebrew?

2

I created Homebrew-command-not-found just for that. It works exactly as you would expect, and supports 4800+ Homebrew formulae. We currently support Bash and Zsh, and there’s an open pull-request for Fish support.

However it’s currently limited to correct spellings, e.g.:

$ ghc
The program 'ghc' is currently not installed. You can install it by typing:
  brew install ghc
$ ghv
ghv: command not found

Install it with brew tap homebrew/command-not-found, then add the following line to your ~/.bashrc/~/.zshrc:

if brew command command-not-found-init > /dev/null; then eval "$(brew command-not-found-init)"; fi

We’d welcome a PR for misspelling support, though.

4

Searching Google for "homebrew command-not-found" (without the quotes) one of the results was: Ubuntu’s command-not-found equivalent for Homebrew on OSX

I have not personally tried using it, so I cannot comment on how well it may work.

  • Homebrew-command-not-found creator here. It works well but doesn’t support misspellings. – bfontaine Aug 26 '15 at 10:51
1

One option is to use zsh, which has a CORRECT option that will suggest commands with a "nearby" spelling. Personally, I use zsh and prezto, which results in this:

zsh and prezto auto correct

It's nice because the command is red while typing if it's not a valid program name, which means I usually catch the typo before I even press enter. Valid command names are green, though, so I know when I've typed it right.

zsh can be installed via homebrew, and then adding something like prezto on top of that is easy (it's just a git clone ..., ln -s ..., and chsh -s /usr/local/bin/zsh).

You must log in to answer this question.

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