I added this to my ~/.bash_profile
in "Bash on Ubuntu on Windows" (and I have git
installed):
# Get the Git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Custom bash prompt
#
# Includes custom character for the prompt, path, and Git branch name.
#
# Source: kirsle.net/wizards/ps1.html
export PS1="\n\[$(tput bold)\]\[$(tput setaf 5)\] \[$(tput setaf 6)\]\w\[$(tput setaf 3)\]\$(parse_git_branch) \[$(tput sgr0)\]"
When entering a new bash shell, I don't see this change in effect. What am I doing wrong?
My ~/.bashrc
is untouched and at its default.
If I add the code above to ~/.bashrc
, it works. But I don't want to clobber with customizations.
~/.bash_profile
is not sourced. You should put it in~/.bashrc
(as you noticed it works there) - that's the normal place to set the prompt.