I'm running several web applications in my VM which is on Ubuntu 12.04.
I find myself typing the following very often when I ssh into my VM.
cd /var/virtual/app1.com/
cd /var/virtual/app2.com/
cd /var/virtual/app3.com/
Each line represents a separate webapp root directory for me to perform certain instructions.
This is the lazy programmer asking if there is a way for me to type.
go_app1
go_app2
go_app3
I know how to do the above using bash script.
but I will end up typing
./GoApp.sh -app app1
I want to make it more elegant by simply typing go_app1.
Advice?
EDIT:
I used the top-rated answer and I got this error message in Ubuntu.
https://gist.github.com/simkimsia/7336019
Where did I go wrong?
EDIT2:
I have rewritten the error into another question here at command not found message when I try to add command in .bashrc.
Defining an alias for each will certainly work. But since you have multiple desired shortcuts following a pattern, consider a function.
function go_app() { cd /var/virtual/app$1.com/; }
Usage:
go_app 1
Put the function definition in ~/.bashrc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With