How can I create a custom terminal command (to run a script)?
A common way people handle this is to make a bin
directory in their home directory: mkdir ~/bin
Then, you can put your custom scripts in there: mv start-working ~/bin
Make sure your script is executable: chmod +x ~/bin/start-working
Add this to the bottom of your ~/.bashrc
file (if you're using bash, which you probably are): export PATH=$PATH:~/bin
Now log back in and out of your terminal and you should be able to simply type start-working
, and your script will execute.
Now that your path is setup, any new scripts you drop into your ~/bin
you can just type in the name of.
I was looking how to create custom commands and I found this question among others. I think what I was looking for was for aliases so I'll give you the way to do this with an alias.
On your home folder:
nano .bash_aliases
And there you can write down your commands in one line:
alias start-working='sudo service apache2 start; sudo service mysql start; sublime'
After saving the file reconfigure your bashrc
. ~/.bashrc
And check your new alias is loaded
alias
That's it, you can start working now by running
start-working