Setting up a bash alias

In my day-to-day work I am using Vagrant with VirtualBox which provides an easy to setup development environment pre-configured with ubuntu, php, mysql and nginx.

One thing that helps save time is reducing the time spent writing terminal commands, this is where a bash alias comes in handy.

To set one up you need to ssh into the vagrant machine (I use putty on windows), and then type in

vim ~/.bashrc

this opens your bashrc file in the editor vim, to begin editing the file use the insert (ins) key.

You can add your alias's anywhere in this file.

alias gs="git status"

After typing your aliases in you need to first exit insert mode by pressing Esc, then type :w and hit enter to save your changes and :q should quit vim.

To check our alias works without requiring a machine reboot we need to apply the changes from our .bashrc file, to do this from the terminal type

source ~/.bashrc

Your aliases should now work

One handy alias I like to add is alias reload=". ~/.bashrc" - This allows me to just type reload in my shell after making changes to my rc file instead having to type . ~/.bashrc, while this isn't many keystrokes, it is a lot easier to remember (although I have muscle memory for both at this point).