Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Note that I only want user's input to have specific color (words that user has typed with keyboard), not the actual command's output.

I tried:

export PS1="$ \033[38;5;154m"

I know that it should be closed with \033[m but I have no clue how to insert it after the input was sent to stdin.

export PS1="$ \033[38;5;154m$PS1\033[m"

This doesn't work either.

The reason why I want this is to be able to easily distinguish the input command from it's output. Thanks in advance.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Bash won't be able to color all user input. UNIX is full-duplex and all data displayed comes from the unix machine, not from the local terminal emulator/keyboard so the terminal emulator (xterm?) can't really tell the difference, and bash only controls what it does, not what every program does.

I use a different colored prompt.

if [[ "$EUID" -eq 0 ]]; then PC="$COLORred"; fi
PS1="\[$PC\]#===> \@ %\j / \u @ \h : \w/\n#===> \\\$ \[$COLORreset\]"

# Print when exit status is not 0 -- I like this too... shown in red
export PROMPT_COMMAND="x0=\$?;if ((\$x0 > 0)); then echo '${COLORred}# exit status = '\$x0' -- From PROMPT_COMMAND$COLORreset'; fi"

Maybe check

share|improve this answer

I don't think you can get a different color for input commands and their output. In any case, you certainly cannot do this by setting the PS1 variable. The PS1 is the prompt, the text displayed to the left of whatever you type in. For example:

enter image description here

You can change the default colors of the terminal by modifying your .Xdefaults and/or .Xresources file. Have a look here, here and here for some more information.

share|improve this answer

Your Answer


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.