# ubuntu terminal under command line Color configuration # parses out the branch name from. Git/head:find_git_branch () {local dir=. Headuntil ["$dir"-ef/]; Doif [-F "$dir/.git/head"]; Thenhead=$ (< "$dir/.git/head") if [[$head = Ref:\ refs/heads/*]]; Thengit_branch= "[→${head#*/*/}]" elif [[$head! = ']]; Thengit_branch= "[→ (detached)]" elsegit_branch= "[→ (Unknow)]" fireturnfidir= ". /$dir ' donegit_branch= '} # git directory displays the current branch prompt_command= "Find_git_branch; $PROMPT _command "# Here's bash color codes you can useblack=$ ' \[\e[1;30m\] ' red=$ ' \[\e[1;31m\] ' green=$ ' \[\e[1;32m\] ' yellow=$ ' \[\e[1;33m\] ' blue=$ ' \[\e[1;34m\] ' magenta=$ ' \[\e[1;35m\] ' cyan=$ ' \[\e[1;36m\] ' white=$ ' \[\e[1;37m\] ' normal=$ ' \[\e[m\] ' ps1= $magenta \[email protected] $green \h$white: $cyan \w$yellow\ $git _branch$white$red\$ $normal "
usage: Append the above code to the ~/.BASHRC file, after the source ~/.BASHRC opens the new terminal can see the effect
Shell color and show git branching configuration