Created
March 16, 2012 12:37
-
-
Save clauswitt/2049889 to your computer and use it in GitHub Desktop.
Git zsh aliases and functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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