How can I complete directory entries that are under a subdirectory?

4

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?

mattr-

Posted 2013-09-23T02:56:23.667

Reputation: 181

Answers

2

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

mattr-

Posted 2013-09-23T02:56:23.667

Reputation: 181