views:

14

answers:

1

I'm frequently using the cli (terminal) on Linux and Mac.

How can I save time by setting a variable to the current project folder instead of

cd path/to/folder/over/and/over/again

Something like

cd the-current-project

(with tab completion) ?

+3  A: 

Depending on your shell, you can set a cdpath with directories you regularly cd to, and so you can do just what you want:

cd the-current-project

from anywhere. See here for more details.

Alternatively you can just set a shell variable and

cd $CURRENT_PROJECT

Again, your shell will determine whether you can tab-complete this (I know zsh will do this. I'm not sure about bash).

Brian Agnew
Awesome. Thanks!
Rimian
+1, didn't know about `CDPATH`. Does it also work in conjunction with `pushd` and `popd`? So you `pushd` to a "favourite" in `CDPATH` then `popd` straight back to where you were?
shambulator
It does (again, in zsh. Not sure about bash, ut I'd hope so)
Brian Agnew