2

I've recently tinkered with my .bash_profile to change the color and formatting of my Terminal command prompt. Unfortunately, in doing so, I've also caused for any text that I type in to appear in a very transparent shade:

enter image description here

Below are the contents of my .bash_profile:

PS1="\[\033[0;35m\]\u\[\033[1;33m\]@\[\033[1;33m\]\w\[\033[0;32m\]\$ "
export PS1;

export CLICOLOR=1
export LSCOLORS=Gafxcxdxbxegedabagacad

How might my .bash_profile file be modified to make all text as bright/bold as the bold-green and bold-yellow text shown in the image?

kramsiv94
  • 641
  • 3
  • 13
  • 31

3 Answers3

1

Setting the PS1 variable using escape codes is tedious and often has side effects. I did it that way for years, and line wrapping was often broken. I tested your PS1 in a terminal window. Seems that something is not terminated correctly as the color bleeds into the following line. I use tput to set PS1, which makes the assignment more readable. Here is what I have in .bash_profile:

set_prompt() {
local red=$(tput setaf 1)
local green=$(tput setaf 2)
local yellow=$(tput setaf 3)
local blue=$(tput setaf 4)
local magenta=$(tput setaf 5)
local cyan=$(tput setaf 6)
local white=$(tput setaf 7)
local reset=$(tput sgr0)

if [ ${UID} -eq 0 ]; then
    # user is red when we are root
    export PS1="\[$red\]\u\[$white\]@\[$green\]\h\[$white\]:\[$yellow\]\w [$reset\]$ "
else
    export PS1="\[$blue\]\u\[$white\]@\[$green\]\h\[$white\]:\[$yellow\]\w\[$reset\]$ "
fi;

}

# Don't set the prompt for dumb terminals
if [ ${TERM+x} -a "${TERM-}" != "dumb" ]; then
    set_prompt
fi
Fuligo septica
  • 117
  • 1
  • 7
0

The brighter text was from this chunk, which sets the bold attribute 1:

\[\033[1;33m\]

and the text is left dim because you omitted bold at the end:

\[\033[0;32m\]

The 32 and 33 select colors green and yellow, respectively, but without the bold attribute, most terminals display that as brown.

Further reading

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
-1

I am using macbook too but I don't use the default terminal application. I use iTerm, it is really more flexible and can be configured as how you want it to display things.

JekBP
  • 81
  • 4