I'd like to color the prompt and command of my shell differently from the text printed in the output stream.

My current export for PS1 is as follows:

export PS1="\e[0;36m\h:\e[m \e[1;33m\w\e[m\[\033[32m\]\$(parse_git_branch)\[\033[00m\]\n\e[0;37m➜\e[m "

I'm coloring the first line of the multi-line prompt correctly, but in the second line I'd like to color both the prompt arrow and the command itself white, while preserving the output as gray.

For example, see the following screenshot of my shell. I'm attempting to color the command ls white in addition to the prompt arrow , but nothing else. I haven't been able to figure out how to color the command without changing the text color setting for the entire Terminal theme.

Screenshot of shell output

Different colors for text entry and console output explains how to do it:

export PS1="\e[0;36m\h:\e[m \e[1;33m\w\e[m\[\033[32m\]\$(parse_git_branch)\[\033[00m\]\n\e[0;37m➜ "
trap 'echo -ne "\e[0m" ' DEBUG

Should do what you want:

enter image description here

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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