Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way for the command line and the output to be in different colors? For example, I've been playing with the PS1 value so my prompt is in red, but I'd like to have the command line in green and the output in white (ex: if I type "ls", that's in green, and then the file list is in white).

share|improve this question

2 Answers

You need to have the shell, or a program, emit the appropriate escape sequence to change the colours after you press enter.

The bash shell used by current OS X doesn't have an obvious facility for doing this.

share|improve this answer
Is there any way to alias a return key to be "color escape sequence + return"? – punkkat Jun 27 '12 at 20:38

You could bind another key to send the escape sequence and a return.

  1. In Terminal's preferences, click on the Settings pane, then the Keyboard tab.
  2. Click the plus button.
  3. Choose a modifier and key. Set the action to send string to shell and the string to \033[m\015. Click OK.

You'll have to get used to using that keyboard shortcut instead of return…although there's probably an app that will let you the system treat return in Terminal as that alternate shortcut.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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