Shell color and show git branching configuration

Source: Internet
Author: User

# 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.