A daily routine of cd’ing in a directory and starting a server can easily be automated.
How to shortcut on Linux
- Save your script wihtout ending i.e. as “x” in any dir
Best create a new folder for your custom scripts i.e.
/home/dome/mycommands/
1
2
3
4
5
| #!/bin/bash
function startr(){
cd /home/dome/app && rails s -b 0.0.0.0
}
startr
|
- Add permanent path to .bashrc file
add line:
1
| export PATH=$PATH:/home/dome/mycommands
|
Exit file and save with ctrl+x, then confirm with y.
- Add missing permissions with
1
| sudo chmod a+rwx /home/dome/mycommands/x
|
- Ready! Now when executing your script as source (the dot) by typing
it will cd and start the rails server.