Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.