Recognise command and colour it on the terminal?

Solution 1:

Not a bash answer, as I don't have one, but if you switch your shell to zsh (a close relative of bash) and install the configuration framework prezto you'll get this functionality more or less out of the box, as well as significantly better autocompletion. Switching to zsh most likely won't change your day to day bash workflow at all, but it'll open a a lot of doors in terms of customisation and extension, and also adds some clever features worth learning - like shared command history across all prompts that can be included in the autocompletion dictionary, file globbing to efficiently work with multiple files at once, and most importantly compatibility modes, whereby zsh can emulate another shell - meaning that if some of your bash scripts don't work the way they used to after switching to zsh, you can just emulate it - although personally all the bash scripts I've written still worked fine in zsh.

Useful links:

  • Installing the latest version of zsh in OS X
  • Installing prezto
  • Some in-depth discussion of how switching can improve your workflow