Created
May 29, 2025 08:07
-
-
Save andy5995/fcbb02ec5785fefb6104f94a6911625f to your computer and use it in GitHub Desktop.
Change prompt to show git branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ~/.bashrc | |
| show_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
| } | |
| if ${use_color} ; then | |
| ... | |
| if [[ ${EUID} == 0 ]] ; then | |
| PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] ' | |
| else | |
| PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]$(show_git_branch)\$\[\033[00m\] ' | |
| fi | |
| ... | |
| else | |
| ... | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment