I want to display my current branch status (like * meaning modified) when in a git repo over the terminal like the below. BUT, it is always displaying the following even when I switch to a git repo.
ᴾᴋᴹɴ iFeelNewsBot master wrong... ↪
When I open a new tab in my terminal it shows the proper text rendering for the current git branch seen further. How it should look
ᴾᴋᴹɴ iFeelNewsBot master * ↪
My custom bash profile code is below
# user name and color
USER_NAME='mr.universe';
TRAINER_TITLE='ᴾᴋᴹɴ'
USER_NAME_COLOR='\[\033[00m\]';
END_COLOR='\e[0m';
# \W = current working path
# \u = user
function parse_git_dirty {
gitStatus=$(git status 2> /dev/null | tail -n1)
clean="nothing to commit, working directory clean"
if [[ -d "./.git" ]]
then
[[ $gitStatus != $clean ]] && echo "*" || echo "="
elif [[ ! -d "./.git" ]]
then
echo "wrong...."
else
echo "STOP"
fi
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1="\[\033[40;02m\]$TRAINER_TITLE \W \[\033[36;02m\]\[\033[29;00m\]\$(git branch 2>/dev/null | grep '^*' | colrm 1 2) $(parse_git_dirty) ↪ "