Skip to content

Instantly share code, notes, and snippets.

@brennandunn
Created August 7, 2008 18:58
Show Gist options
  • Save brennandunn/4467 to your computer and use it in GitHub Desktop.
Save brennandunn/4467 to your computer and use it in GitHub Desktop.
if [[ -x `which git` ]]; then
function git-branch-name () {
git branch 2> /dev/null | grep ^\* | sed s/^\*\ //
}
function git-dirty () {
git status | grep "nothing to commit (working directory clean)"
echo $?
}
function gsrb () {
branch=$(git-branch-name)
git checkout master
git svn rebase
git checkout "${branch}"
git rebase master
}
function git-prompt() {
branch=$(git-branch-name)
if [[ x$branch != x ]]; then
dirty_color=$fg[cyan]
if [[ $(git-dirty) = 1 ]] { dirty_color=$fg[magenta] }
[ x$branch != x ] && echo " %{$dirty_color%}$branch $(git-stash-count)%{$reset_color%} "
fi
}
function git-stash-count() {
branch=$(git-branch-name)
count=$(git stash list | grep "${branch}" | wc -l | awk '{print $1}')
[ $count != 0 ] && echo "($count)"
}
alias derby="git-log | git-shortlog -n -s"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment