Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
2  
possible duplicate –  jw013 Nov 28 '12 at 16:30
add comment

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 Answer

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.

share|improve this answer
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
add comment

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