Home > Blockchain >  How do I set the color of my host name in my bash prompt on macOS Monterey?
How do I set the color of my host name in my bash prompt on macOS Monterey?

Time:05-24

I have the following line in my .bash_profile file to set up my custom bash prompt;

export PS1='\e[0;32m \[`[ $? = 0 ] && X=2 || X=1; tput setaf $X`\]\h\[`tput sgr0`\]:\w\$ \e[m'

but the color of the host name is a slightly darker green color compared to the rest of the prompt as shown. How can I set the whole bash prompt to be the same color of light green?

Picture of my bash prompt

CodePudding user response:

Number 2 is dark green, try 10(==8 2) :

export PS1='\e[0;32m \[`[ $? = 0 ] && X=10 || X=1; tput setaf $X`\]\h\[`tput sgr0`\]:\w\$ \e[m'
  •  Tags:  
  • bash
  • Related