I am trying to add Git branch name to my Bash prompt by changing the PS1 variable like this:
PS1=`echo "$PS1" | sed 's/\\\\\$ $/\$(__git_ps1)\\\\\$ /'`
And if I understand correctly, it is not recommended to update ~/.bashrc for personalizing purposes. All articles I found suggest updating either .profile or .bash_profile for such purposes. So I am looking for a perfect place to put this line into.
These are the places I've tried so far:
.profile: not sourced bygnome-terminal.bash_profile: not sourced bygnome-terminal.bash_login: not sourced bygnome-terminal.bash_aliases: works, but I don't thinkPS1has anything to do with aliases
I am using Ubuntu Desktop and I work in gnome-terminal or byobu, so I have to find a file which is sourced when I start bash in an X environment. Then I looked in .bashrc for other files it sources after assigning a value to PS1. There are .bash_aliases and /usr/share/bash-completion/bash_completion which I don't think are proper for this purpose.
What are other choices? And what is the best practice of customizing Bash prompt?
PS1="${PS1/\$ /\$(__git_ps1)\$ }". – muru Mar 13 '15 at 08:47PS1="${PS1/%\\$ /\$(__git_ps1)\\$ }". – Sah Mar 18 '15 at 03:04