# source ~/.git_auto_complete.sh
if [[ -x `which git` ]]; then
# Promt Work
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 git-prompt() {
branch=$(git-branch-name)
if [[ x$branch != x ]]; then
dirty_color=$fg[green]
if [[ $(git-dirty) = 1 ]] { dirty_color=$fg[red] }
[ 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)"
}
# SVN Macros
function gsrb () {
branch=$(git-branch-name)
git checkout master
git svn rebase
git checkout "${branch}"
git rebase master
}
function gsu () {
git checkout master
git svn rebase
}
function gsrbc () {
branch=$(git-branch-name)
gsrb
git checkout master
git rebase "${branch}"
git svn dcommit
git checkout "${branch}"
}
# Other Macros
function gmrb () {
branch=$(git-branch-name)
git checkout master
git pull origin master
git checkout "${branch}"
git rebase master
}
function gtag () {
git tag -a -m "Tagging Version ${1}" $1
git push origin master
git push --tags
}
function ginit_xcode () {
git init
gignore_xcode
git add .gitignore
git commit -m "Ignore Xcode stuff."
git add .
git commit -m "Initial Xcode project."
}
fi
# Logging
alias gfame='git log | git shortlog -n -s'
alias gfame2="ruby /Scripts/gscore.rb"
alias glog="git log --pretty=oneline"
alias glog_ss="git log --shortstat"
alias glog_ns="git log --name-stat"
alias glog_p="git log -p"
alias glog_s="git log --pretty=short"
# Rebasing
alias grc='git rebase --continue'
alias grs='git rebase --skip'
alias gra='git rebase --abort'
# Diff
alias gd='git diff'
alias gdm='git diff | mate'
# Unorganized
alias gst='git status'
alias gl='git pull'
alias gp='git push'
alias gr='git remote'
alias ga='git add -i'
alias gco='git checkout'
alias gc='gitx -c' # git commit -v
alias gca='git commit -v -a'
alias gspp='git stash pop'
alias gb='git branch'
alias gba='git branch -a'
# Svn Helpers
alias gsp="git svn dcommit"
# Utilitarian
# alias grmut='git ls-files -o --exclude-from=.gitignore | xargs rm'
alias grmut='git ls-files -o | xargs rm'
alias gits="ls /opt/local/bin/ | grep git"
alias gh="github"
alias grb_gh="open http://github.com/webmat/git_remote_branch/tree/master"
alias gignore_xcode='echo "\n\n# XCode\nbuild\n*.mode1v3\n*.mode2v3\n*.nib\n*.swp\n*.pbxuser\n*.perspective\n*.perspectivev3\n\n# OSX\n.DS_Store\n\n# TextMate\n*.tm_build_errors\n\n\n" >> .gitignore'