Skip to content

Instantly share code, notes, and snippets.

@rody
rody / gist:3750294
Created September 19, 2012 15:32
bash script for a nice Git-aware prompt showing current branch and status
# Scavenged from Git 1.6.5.x contrib/completion/git_completion.bash
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# returns text to add to bash PS1 prompt (includes branch name)
__gitdir ()
{
if [ -z "${1-}" ]; then
if [ -n "${__git_dir-}" ]; then
echo "$__git_dir"
elif [ -d .git ]; then
echo .git