Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change the input color of my Bash prompt to something different than the terminal default? [closed]

My default terminal color is gray, and that's fine.

My Bash prompt displays a bunch of colors, and this works fine:

PS1="${COLOR_RED}\u${COLOR_WHITE}@${COLOR_RED}${COMPUTERNAME} ${COLOR_BLUE}\w${GITPROMPT} ${COLOR_RESET}"

But the text I type in, at the end of the prompt, is gray. I want it to be white (ANSI code "[37m").

If I add a COLOR_WHITE at the end of the prompt, instead of the COLOR_RESET, then the default terminal color changes to white until it is reset. This makes a weird effect of some gray text, with some white text bleeding through at the top.

How can I change the "input text" color of the Bash prompt, to something other than the terminal default color?

like image 485
dylanized Avatar asked May 19 '13 14:05

dylanized


2 Answers

Simply add the following line:

export PS1=" \[\033[34m\]\u@\h \[\033[33m\]\w\[\033[31m\]\[\033[00m\] $ "

Preview:

Enter image description here

These are my preferred colors. You can customize each part of the prompt's color by changing m codes (e.g., 34m) which are ANSI color codes.

List of ANSI color codes:

  • Black: 30m
  • Red: 31m
  • Green: 32m
  • Yellow: 33m
  • Blue: 34m
  • Purple: 35m
  • Cyan: 36m
  • White: 37m
like image 93
Shayan Amani Avatar answered Oct 21 '22 07:10

Shayan Amani


Try this one. It is simpler:

export PS1="\e[0;32m\t \e[32;1m\u@\h:\e[0;36m\w\e[0m$ "
like image 24
dlink Avatar answered Oct 21 '22 07:10

dlink