MAC, Linux system terminal shows git current branch

Source: Internet
Author: User

1 Go to your home directory

CD ~

2 Edit. bashrc file

VI. BASHRC

3 Add the following code to the end of the file

function git_branch {  Branch= "' Git branch 2>/dev/null | grep" ^\* "| sed-e" s/^\*\//"'"  if ["${bra NCH} "! =" "      ];thenif [" ${branch} "=" (No branch) " ];then          Branch=" (' Git rev-parse--s Hort HEAD ' ...) '       fi      "($branch)"  fi}export PS1= ' \[email protected]\h \[\033[01;36m\]\w\[\033[ 01;32m\]$ (git_branch) \[\033[00m\] \$ '
 

4 Save Exit


5 Executing the load command

source./.BASHRC
 

6 Complete

The shell launched under MAC is the login shell, so the configuration file loaded is. bash_profile and will not load. BASHRC. If you're a MAC user, you'll need to execute the following command, which will automatically take effect every time you turn it on:

echo "[-R ~/.BASHRC] && source ~/.BASHRC" >>. Bash_profile
 

MAC, Linux system terminal shows git current branch

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.