Skip to content

Instantly share code, notes, and snippets.

@saranrapjs
Created March 12, 2012 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saranrapjs/2024853 to your computer and use it in GitHub Desktop.
Save saranrapjs/2024853 to your computer and use it in GitHub Desktop.
Git status in bash prompt
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}") "
}
YELLOW="\[\033[0;33m\]"
PS1="\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)\[\e[m\]\$ "
@saranrapjs
Copy link
Author

based on http://railstips.org/blog/archives/2009/02/02/bedazzle-your-bash-prompt-with-git-info/
using 1.7.9 (though I believe the above git syntax requires >1.6 )

@saranrapjs
Copy link
Author

add to your .bash_profile !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment