how do I concatenate a regex in a bash alias?

Posted by Rodreegez on Super User See other posts from Super User or by Rodreegez
Published on 2010-05-11T17:00:01Z Indexed on 2010/05/11 17:04 UTC
Read the original article Hit count: 157

Filed under:

Hello,

I can't for the life of me how to create an alias that will switch to a given project directory.

I keep all my projects in a folder called Projects i.e. ~/Project/blog ~/Project/whatever

I'd like to have an alias along the lines of p whatever that would equate to cd ~/Project/$1 where $1 is whatever is given to p.

I have tried various combinations of alias p="cd ~/Projects/\$1" with all the usual suspects for regex escaping but I can't quite get it.

Any ideas?

© Super User or respective owner

Related posts about bash