Git分支名称不会在Mac终端上显示

问题描述 投票:0回答:1

我在Mac的~/.bash_profile中添加了以下几行:

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

#Variables
userName="\u"
fullPath="\w"
systemName="\h"

#'$(tput setaf 14)' allows coloring for the prompt
#that immediately follows it. 14 is the color aqua.
#A list of colors can be accessed below:
#https://jonasjacek.github.io/colors/

#`$(tput sgr0)` stops the text coloring from continuing on.

Personalized Terminal
PS1="\[$(tput setaf 118)\]${userName}\[$(tput setaf 3)\]@${systemName}\[$(tput setaf 14)\]${fullPath}\[$(tput setaf 222)\]\[$(parse_git_branch)\]\[$(tput setaf 160)\]$ \[$(tput sgr0)\]"
export PS1;

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

#------- Aliases -------

#Open Sublime Text Editor
alias subl="open -a /Applications/Sublime\ Text.app"
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

终端样式看起来不错,但是我的parse_git_branch没有显示我的git分支的名称。我搞砸了PS1值的定义,但不确定自己做错了什么。

bash git
1个回答
0
投票

只需注释掉Personalized Terminal,那应该解决它。它对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.