A bash alias is nothing more than a shortcut. Using bash you can create aliases as a way to simplify repetitive tasks. With this example you can download and unpackage drupal with a single command. For this guide open up terminal and navigate to a directory where you want to install drupal.
Create a folder and change directory into it.
Okay now lets add the command chain to your bash_profile so that you can use it everytime you boot up terminal. Depending on whether you have already have an exisintg bash_profile this file may be blank, but that is okay we can create one now.
sudo pico ~/.bash_profile
The full alias is written below, copy and paste this into your terminal window. I have choosen drupal7 as my command to execute the following alias.
alias drupal7="wget http://ftp.drupal.org/files/projects/drupal-7.32.tar.gz; tar xvzf drupal-7.32.tar.gz; rm drupal-7.32.tar.gz; mv drupal-7.32 public_html;"
Lets break this down:
Using wget we can download the latest drupal version from drupal.org
Once downloaded we want to unpackge the zip using tar
tar xvzf drupal-7.32.tar.gz
We want to clean up the directory by removing the download zip file
Last we want to change the name of the directory to something more suiting, in my case I like to use public_html.
mv drupal-7.32 public_html
Now the fun part, in order to use this you will need to save the file by writing out control + O then Return to confirm, and last control + X to close the file. Restart Terminal and return to your directory, if it doesn't not open automatically. Simply type drupal7 (you can change this) into your terminal and you should see the download begin. Type ls to list your contents, you should now see the file public_html. Congratulations, you just set up an alias! Aliases are really useful and can be used to set up many different tasks. This example is only the beginning.
If you have any questions about setting up bash aliases, feel free to get in touch. We're here to help!