Last Updated: February 25, 2016
·
934
· supermarin

Shell `cd`replacement

Everybody has one of those ~/code, ~/dev, ~/development, ~/workspace, ~/you-name-it folders.

We have many projects inside and we like to group things.
For instance, if I want to hack on Cocoapods/Core, here's what I need to type:

$ cd code/OSS/Cocoapods/Core

Or, if I've just checked out some random open source stuff,

$ cd code/Playground/RandomProject

As you may cd to projects many times a day, this one might help you:
(It's also case-insensitive)

# wo = work on
wo() {
  code_dir=~/code # replace it with your development directory
  cd $(find $code_dir -type d -maxdepth 3 | grep -i $* | grep -Ev Pods --max-count=1)
}

Just copy this to your .bashrc, or .zshrc, or even better, .aliases if you keep a separate file for them.

Usage:

$ wo core
# enters ~/code/OSS/Cocoapods/Core on my machine

$ wo sugar
# enters ~/code/OSS/ObjectiveSugar

Note that you can also switch between projects, without cd ..

1 Response
Add your response

Cool script! I'm gonna try it out.

over 1 year ago ·