g alias for git

With arguments, g acts like git.
Without arguments, it runs `git status`.

* Source functions/* after loading ZSH completion so `compdef` is available to g
  alias
This commit is contained in:
Gabe Berke-Williams 2013-03-01 23:32:03 -05:00
parent 1f4e6d1370
commit 89b60fcb49
3 changed files with 16 additions and 5 deletions
aliases
zsh/functions
zshrc

View file

@ -14,7 +14,6 @@ alias e="$EDITOR"
alias v="$VISUAL"
# git
alias g="git"
alias gci="git pull --rebase && rake && git push"
# Bundler

12
zsh/functions/g Normal file
View file

@ -0,0 +1,12 @@
# No arguments: `git status`
# With arguments: acts like `git`
g() {
if [[ $# > 0 ]]; then
git $@
else
git status
fi
}
# Complete g like git
compdef g=git

8
zshrc
View file

@ -1,14 +1,14 @@
# load our own completion functions
fpath=(~/.zsh/completion $fpath)
for function in ~/.zsh/functions/*; do
source $function
done
# completion
autoload -U compinit
compinit
for function in ~/.zsh/functions/*; do
source $function
done
# automatically enter directories without cd
setopt auto_cd