Alias in zsh with completion

I use the shell. I use the shell a lot. I type git so often it’s ridiculous. We have shell aliases to make stuff like this a bit shorter, but often with less functionality. In particular, an alias in itself won’t maintain the completion function, but this is easy to fix:

alias g=git
compdef g=git

And boom! You can now do g st<TAB> to complete status or whatever, this technique will also work any other alias/completion function as well.

Follow me on Twitter to keep up with what I’ve learned building my personal finance tool, Stash.

Read more posts …
Written: August 8th, 2012
Categories: zsh, git, shell, alias, completion, compdef