Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
367 views
in Technique[技术] by (71.8m points)

zshrc - How do zsh ansi colour codes work?

I want to make my hostname in my terminal orange. How do I do that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Running the following code in your terminal should tell you whether your terminal supports 256 colors.

for COLOR in {0..255} 
do
    for STYLE in "38;5"
    do 
        TAG="33[${STYLE};${COLOR}m"
        STR="${STYLE};${COLOR}"
        echo -ne "${TAG}${STR}${NONE}? "
    done
    echo
done

it also shows you the code for each color in the form 38;5;x where x is the code for one of the 256 available colors. Also, note that changing the "38;5" to "48;5" will show you the background color equivalent. You can then use any colors you like to make up the prompt as previously mentioned.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...