Skip to content

Instantly share code, notes, and snippets.

@teja-94
Forked from justintv/.bashrc
Created June 16, 2020 16:59
Show Gist options
  • Save teja-94/d2db15982a3dac7b554a5310ffb3a3b3 to your computer and use it in GitHub Desktop.
Save teja-94/d2db15982a3dac7b554a5310ffb3a3b3 to your computer and use it in GitHub Desktop.
Display git branch in bash prompt
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"
# ~/code/web:master$ git checkout beta_directory
# Switched to branch "beta_directory"
# ~/code/web:beta_directory$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment