Я добавил следующие строки к моей маме c ~/.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
, но я не уверен, что сделал неправильно.