Skip to content

Instantly share code, notes, and snippets.

@stubbetje
Created April 23, 2009 08:20
Show Gist options
  • Save stubbetje/100389 to your computer and use it in GitHub Desktop.
Save stubbetje/100389 to your computer and use it in GitHub Desktop.
show git branch and dirty state in bash prompt
#!/bin/bash
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/';
}
parse_git_dirty() {
[[ ! $(git status) =~ "nothing to commit (working directory clean" ]] && echo " ⚡ "
}
export PS1='\[\033[01;30m\] [$(parse_git_branch)\[\033[01;33m\]$(parse_git_dirty)\[\033[01;30m] \[\033[00m\]'$PS1
export LESS="$LESS -R"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment