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
.
精彩评论