2

I want Input and Output to be different colors in a GNU or Linux bash terminal shell.

I use terminals all the time for bash, R, and python. Today I am fighting all day long to read my R and I have to manually put lots of CRLF to separate and find my place all the time.

So can you help me get terminal I/O to have different Input color and Output color?

  • What terminal client are you using? – Julie Pelletier Feb 7 '17 at 18:57
  • The client is the best place to set background colors. I use 6 different colors to distinguish between the machines I'm connected to. – Julie Pelletier Feb 7 '17 at 20:37
  • Could you please add examples of what you mean by "input" and "output" colors? The shell prompt? The command you're typing? The data printed by your application? A question asked by your application? An answer you're typing to that app? ... – egmont Feb 9 '17 at 1:16
0

It's a bit of a hack, but you can set a DEBUG trap. From trap's documentation:

If a SIGNAL_SPEC is DEBUG, ARG is executed before every simple command

You can set a TRAP which will echo ANSI color codes to the console (e. g. echo -e "\e[1;33;44m" which will change the color of output (notwithstanding any further changes by the output itself). You can also set PROMPT_COMMAND or PS1 to change the color of text which you input at the prompt for the purposes of differentiation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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