Last Updated: February 25, 2016
·
875
· dpashkevich

Quickly jump to a project in shell

I have all my projects sitting under ~/projects/ directory. I work in console quite often and got tired of typing cd ~/projects/<project name>/, so I wrote this tiny shell function that saves numerous keystrokes:

prj() { cd "$HOME/projects/${*}"; }

Usage:

prj awesome       # changes directory to ~/projects/awesome
prj awesome/src   # go straight to /src subdirectory of a project 
prj hello world   # correctly works with spaces in dir names

Just put the function definition into your ~/.bashrc file.

P.S. Tested under bash but should work in most shells. You get the idea anyway :)