4

Possible Duplicate:
Customizing bash shell: Bold/color the command

bash $ cat what-i-want
"I want the output be in a different color."

I'd like my commands stand out among the output, without making the prompt overly long. I want to see commands and output in different colors. I understand how to manipulate prompt colors by setting PS1.

Is there a way to change color after I pressed Enter but before the command started executing?

marked as duplicate by derobert, jasonwryan, Renan, Gilles, Mat Nov 29 '12 at 8:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

You could probably use the bind command of bash / readline to do something on Enter (I believe I have seen it mentioned on this site recently, but I'm unable to find it atm).

Another option is creating an alias, you would prepend in front of the command:

$ alias x='echo <ANSI ESCAPE>;'
$ x cat what-you-want

As Kevin pointed out, remember to reset the colour at the beginning of your prompt.

  • 2
    You'd have to add a color reset escape to the beginning of the prompt. – Kevin Nov 28 '12 at 17:03
  • 2
    Regarding “do something on Enter” – note that 1) Enter not always executes the command; 2) not always Enter executes the command. – manatwork Nov 28 '12 at 17:18

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