Displays the current branch of Git in the Mac terminal

Source: Internet
Author: User

1. Enter your home directory

cd~

2. Edit the. bashrc file

vi.bashrc

3. Add the following code to the last point of the file

functiongit_branch {branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"if"${branch}"!= ""];thenif"${branch}""(no branch)" ];thenbranch="(`git rev-parse --short HEAD`...)"fiecho" ($branch)"fi}exportPS1=‘\[email protected]\h \[\033[01;36m\]\W\[\033[01;32m\]$(git_branch)\[\033[00m\] \$ ‘

4. Save and exit
5. Execute 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. Execute the following command so that it automatically takes effect each time it is powered on:

echo"[ -r ~/.bashrc ] && source ~/.bashrc">> .bash_profile

Displays the current branch of Git in the Mac terminal

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.