Skip to content

Instantly share code, notes, and snippets.

@clauswitt
Created March 16, 2012 12: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 clauswitt/2049889 to your computer and use it in GitHub Desktop.
Save clauswitt/2049889 to your computer and use it in GitHub Desktop.
Git zsh aliases and functions
#git aliases
alias gsts='git status --short'
alias c='git commit '
alias gd='git diff '
alias clean='git clean -f'
alias gl='git l'
#git function to add last parameter of last command via git add (used after a diff)
gal() {
last_command=$history[$[HISTCMD-1]];
last_command_array=("${(s/ /)last_command}")
echo $last_command_array[-1];
git add $last_command_array[-1];
}
#git function to checkout last parameter of last command via git checkout
gcl() {
last_command=$history[$[HISTCMD-1]];
last_command_array=("${(s/ /)last_command}")
echo $last_command_array[-1];
git checkout $last_command_array[-1];
}
#git function to run diff on a file
gdl() {
git diff $1
}
#get autocomplete options for gdl command
_gitdiff () {
compadd `git status --short`
}
compdef _gitdiff gdl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment