开发者

shell script to quickly jump to a directory

I am using mac.

When I do

p demo

on my terminal then I want to go to

cd /Users/dorelal/prod_demo

I tried adding following commands to my ~/.bashrc but none of them worked.

开发者_如何学Goalias p='cd /Users/dorelal/prod_$1'

function p {
  cd '/Users/dorelal/prod_$1'
}


This should work

p() {
  cd "/Users/dorelal/prod_$1"
}

Note the double quotes, rather than single quotes, to allow expansion of the $1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜