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?

1
  • 2
    possible duplicate Commented Nov 28, 2012 at 16:30

1 Answer 1

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
  • 2
    You'd have to add a color reset escape to the beginning of the prompt. Commented Nov 28, 2012 at 17:03
  • 3
    Regarding “do something on Enter” – note that 1) Enter not always executes the command; 2) not always Enter executes the command. Commented Nov 28, 2012 at 17:18

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.