Sometimes tedious tasks can be simplified by writing a simple bash script to perform them. Now i will not go into details on how to write scripts in Bash, but instead show how you can easily make your scripts available from anywhere in your terminal.
First off open up a terminal, and in your home directory create a directory named ‘scripts’. As you might have guessed all your scripts will be placed here. For each script file you place here do the following:
chmod +x scriptname.sh
This will ensure that your script is executable, so no more need to type ‘sh’ before running the script. So now you have a directory of executable script, but so far they can only be accessed from either the directory itself, or by typing the path to the script. So we edit our .bashrc file a little. This file is located in your home directory.
Scroll down to the bottom of the file, and add the following line
Of course replace USERNAME with your own username/homedirectory. Now reload the file with
And you are all set. Any shell script you now place in scripts can be executed from anywhere on the system. The only requirement is to chmod +x on the file first 😀