I have set up a custom bash prompt so I can see stuff like the current git branch, npm package version info, the virtual env I'm in, etc. However, when i press the up arrow key to browse the history, the prompt glitches:
Here's what it is normally:
However, when I browse the history, the space between the lambda sign and the command disappears:
It only happens sometimes, and I don't know why. I guess I'm just being picky about a small space, but after spending a lot of time configuring my bash prompt I want it to look perfect.
This is what my .bashrc looks like. I'm using Git Bash for Windows, btw, if that makes a difference:
bashPrompt() {
SYMBOL="λ"
COUNT=(`find ./ -maxdepth 1 -name "package.json"`)
if [ ${#COUNT[@]} -gt 0 ]; then
NPM_PACKAGE_INFO="($(node -p -e "require('./package.json').version"))"
else
NPM_PACKAGE_INFO=""
fi
if [ ! -z "$CONDA_DEFAULT_ENV" ]; then
ENV=" ($CONDA_DEFAULT_ENV)"
else
ENV=""
fi
if [ -d .git ]; then
if [ -z "$(git status --porcelain)" ]; then
echo "[\[\e[0;36;40m\u@\H\]\[\e[0;37;40m]\]\[\e[1;34;40m${ENV}\] \[\e[1;31;40m\w\]\[\e[1;32;40m$(__git_ps1)\] \[\e[0;37;40m${NPM_PACKAGE_INFO}\]\n\[\e[0;37;40m${SYMBOL}\] "
else
echo "[\[\e[0;36;40m\u@\H\]\[\e[0;37;40m]\]\[\e[1;34;40m${ENV}\] \[\e[1;31;40m\w\]\[\e[1;33;40m$(__git_ps1)\] \[\e[0;37;40m${NPM_PACKAGE_INFO}\]\n\[\e[0;37;40m${SYMBOL}\] "
fi
else
echo "[\[\e[0;36;40m\u@\H\]\[\e[0;37;40m]\]\[\e[1;34;40m${ENV}\] \[\e[1;31;40m\w\] \[\e[0;37;40m${NPM_PACKAGE_INFO}\]\n\[\e[0;37;40m${SYMBOL}\] "
fi;
}
PROMPT_COMMAND='PS1="$(bashPrompt)"'