美文网首页
在mac终端显示git分支

在mac终端显示git分支

作者: Luyc_Han | 来源:发表于2018-01-19 16:35 被阅读33次
image.png

继续

首先查看是否存在~/.bash_profile这个文件
终端指令
$~/.bash_profile
如果没有创建
$touch ~/.bash_profile

然后修改~/.bash_profile,在文件最后添加

# Git branch in prompt.

parse_git_branch() {

    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'

}

export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "

注意

如果不显示隐藏文件可以执行下面命令行

显示:defaults write com.apple.finder AppleShowAllFiles -bool true
隐藏:defaults write com.apple.finder AppleShowAllFiles -bool false 

然后重新启动 访达

相关文章

网友评论

      本文标题:在mac终端显示git分支

      本文链接:https://www.haomeiwen.com/subject/epxaoxtx.html