1

In ubuntu (and likely elsewhere), if I misspell a command, the shell suggests similarly spelled commands:

askewchan@foppl:~$ exi
No command 'exi' found, did you mean:
 Command 'ex' from package 'vim' (main)
 Command 'exif' from package 'exif' (universe)
 Command 'exim' from package 'exim4-daemon-heavy' (main)
 Command 'exim' from package 'exim4-daemon-light' (main)
 Command 'esi' from package 'atm-tools' (universe)
 Command 'kexi' from package 'kexi' (main)
 Command 'exp' from package 'alliance' (universe)
 Command 'axi' from package 'afnix' (universe)
exi: command not found

(which didn't work in this case, as I had intended to type exit). Apparently this comes from apt-get install command-not-found, but is there something like this for OS X?

Is there anything similar that would work on OS X or bash in general?

1 Answer 1

1

Well, unless you have fink, brew or macports installed, there isn't a repository for bash to search. Except there kind of is - fish searches man page descriptions (kind of like apropos).

http://fishshell.com/ has "man page completions" which seems relevant:

"Other shells support programmable completions, but only fish generates them automatically by parsing your installed man pages. "

Or zsh has auto-predictions:

https://stackoverflow.com/questions/17223388/fish-style-autosuggestion-in-zsh

If you're ok with hitting tab, which might prevent the typo in the first place?

You can do auto-completion in bash, though it's not as sophisticated as zsh:

Bash completion for commands in Mac OS X

1
  • There must already be the list of executables in PATH or something simpler, how else do all the command autocomplete? To be clear, I don't expect it to search uninstalled packages, just commands that exist. git does this as well, actually.
    – askewchan
    Oct 1, 2014 at 1:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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