Skip to content

Instantly share code, notes, and snippets.

@andy5995
Created May 29, 2025 08:07
Show Gist options
  • Select an option

  • Save andy5995/fcbb02ec5785fefb6104f94a6911625f to your computer and use it in GitHub Desktop.

Select an option

Save andy5995/fcbb02ec5785fefb6104f94a6911625f to your computer and use it in GitHub Desktop.
Change prompt to show git branch
# ~/.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