Skip to content

Instantly share code, notes, and snippets.

@cirpo
Created April 5, 2012 22:24
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 cirpo/2314662 to your computer and use it in GitHub Desktop.
Save cirpo/2314662 to your computer and use it in GitHub Desktop.
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/ "
}
PS1='\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(parse_git_branch)\[\033[0m\]\$ '
export PS1
@mrngm
Copy link

mrngm commented Apr 5, 2012

Might want to export PS1 instead of PSI

@cirpo
Copy link
Author

cirpo commented Apr 5, 2012

thanks :P

@mrngm
Copy link

mrngm commented Apr 5, 2012

Since you've got roughly the same PS1 as I have, here's a nice git alias to put in your ~/.gitconfig
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

It does a git log, but with fancy colours and branch indication.

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