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.

Subscribe to my mailing list to learn more about technology and business.

Your email will never be shared with anyone else.

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