Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created October 21, 2009 02:37
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 metaskills/214798 to your computer and use it in GitHub Desktop.
Save metaskills/214798 to your computer and use it in GitHub Desktop.
# 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 grbm () {
branch=$(git-branch-name)
git checkout master
git pull origin master
git checkout "${branch}"
git rebase master
}
function grbmc () {
branch=$(git-branch-name)
grbm
git checkout master
git rebase "${branch}"
git push origin master
git checkout "${branch}"
}
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 --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"
alias glog_g="git log --graph"
# 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 gr='git remote'
alias ga='git add -i'
alias gco='git checkout'
alias gc='git commit -v' # gitx -c
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 -X .gitignore | xargs rm'
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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment