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:
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?
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
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.