My terminal is now writing over the same line twice. It also does not go to the end before it started to repeat the line. This is in my .bash_profile
c_reset="$(tput setaf 2)"
c_path="$(tput setaf 1)"
c_git_dirty="$(tput setaf 1)"
c_git_clean="$(tput setaf 2)"
c_white="$(tput setaf 7)"
PROMPT_COMMAND=$PROMPT_COMMAND' PS1="${c_path}\W${c_reset}$(git_prompt) :> "'
export PS1='\n\[\033[0;31m\]\W\[\033[0m\]$(git_prompt)\[\033[0m\]:> '
git_prompt ()
{
# Is this a git directory?
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
# Grab working branch name
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
# Clean or dirty branch
if git diff --quiet 2>/dev/null >&2; then
git_color="${c_git_clean}"
else
git_color=${c_git_dirty}
fi
echo "${c_white}[$git_color$git_branch${c_white}]"
}
I get what this code dose. But my issue is it still writes over the same line. I have tried other wyas of doing this. using \003[0;31m type commands for setting the color.
What I am trying to do is get for it to tell when my git is dirty. Right now it writes over the same line in the terminal that I start on. It does this even with trying [ ]. Can someone tell me how to fix this and how the line with PROMPT_COMMAND works.