Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an function in my .zshrc called c that is defined like so

c() {
cd ~/Code/$1

How can I teach ZSH to treat this c function just like I had done cd ~/Code from the command line so that it completes the projects underneath?

share|improve this question
up vote 0 down vote accepted

I found the answer through another search just now. From this answer on Stack Overflow, I added the following to my .zshrc

compctl -/ -W ~/Code c

What do the options do?

  • -/ tells compctl to just complete file system paths
  • -W tells compctl to implicitly add the value ~/Code to the front of the completion.
  • c is the thing to complete
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.