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.

  • 4
    It's happening because the shell you're opening is not a login shell and so ~/.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. – Zanna Oct 11 '16 at 7:53

In "Bash on Ubuntu on Windows", the opened shell is not a "login shell", which means .bash_profile isn't being read, as mentioned by @Zanna (thank you!).

You can use shopt to see whether your'e in a "login shell" or not:

shopt login_shell

Since I wish to keep things tidy and put customizations into their own files, I'm now sourcing a custom file from .bashrc:

  . ~/.bashrc_customizations

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.