# Mac下显示git分支

通常情况下我们在git目录中，使用`git branch`来查看分支，这样很麻烦繁琐，不如直接显示来的直接。下面我们来介绍一下如何在mac的终端中显示git分支。这里提供一个简单的办法，使用zsh并配置，顺便安利一下mac的终极shell——zsh，关于zsh的一些介绍可以参考：<http://macshuo.com/?p=676。本文主要讲如何显示git分支。>

```
# 先来查看一下mac支持的shell：
cat /etc/shells 
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
# 查看当前使用的shell
echo $SHELL
/bin/bash
# 切换成zsh，重启终端后生效
chsh -s /bin/zsh
# 安装on my zsh，假设你已经安装了git
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
# 重启一下终端，然后进入到一个git目录中去，就可以看到分支啦。
```

**注意：**&#x7531;于切换了shell，所以之前在\~/.bashrc里面的配置都不生效了，需要配置在\~/.zshrc里面。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jun-wang.gitbook.io/learnjava/xiaolti-sheng/mac-xia-xian-shi-git-fen-zhi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
