Useful zsh tricks

I’m using zsh on my mac, mostly for its better completion system. A coworker asked me for a couple of tweaks, the answers took a bit to find so here’s a FYI for the command line nerds out there.

Q1: The cd command tab-completes files, which is totally broken.

Fix:

 compctl -/ cd
Q2: Tab-completion for git commands, please
Ans:

 compctl -k "(add bisect branch checkout co clone commit diff fetch grep init log merge mv pull push rebase reset rm show status tag)" git
The second just says that that ‘these words in the array are the arguments for the git command.’
There’s also the vastly more elaborate code here, which modifies the prompt to show git status when in a git-controlled repository. I’m trying that now.

Q3: Fix the prompt when using virtualenv
Ans: See this post (especially read the comments). Looks like 1.6.1 of virtualenvwrapper and newer should ‘just work.’

Leave a Reply