Skip to content

Instantly share code, notes, and snippets.

@clobrano
Created December 9, 2024 08:34
Show Gist options
  • Select an option

  • Save clobrano/c5ff675b275781779dd88e13d97d1ee4 to your computer and use it in GitHub Desktop.

Select an option

Save clobrano/c5ff675b275781779dd88e13d97d1ee4 to your computer and use it in GitHub Desktop.
Bashrc excerpt to view git branch in PS1
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
if whoami | grep root > /dev/null; then
SYM="#"
else
SYM="$"
fi
export PS1="\w\$(parse_git_branch)$SYM "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment