Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse commands and color it?

I like the idea of command prompt coloring, and I was wondering how I can extend that to have the shell color the commands as I type it in or via tab completion. So for example, when I finish typing 'gcc', the shell should recognize that it is a valid command and color it green. If the command is not a recognized command then it should be colored in red and boldfaced.

This feature will help tremendously in typing in correct commands especially if you have long commandlines with pipelined commands which accidentally contain a typo. All command typos will be colored red and boldfaced so that I can easily identify which command I typed incorrectly.

like image 833
QuickMist Avatar asked Jan 23 '26 13:01

QuickMist


1 Answers

I'm not sure that you can do this in bash. But it is possible in other shells, e.g. in zsh (see: https://github.com/zsh-users/zsh-syntax-highlighting ) or in fish (see: http://fishshell.com/ ).

like image 82
Igor Chubin Avatar answered Jan 26 '26 00:01

Igor Chubin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!