fbpx

Bash Aliases to Make Your Life Easier

The BASH shell - Bourne Again SHell
I spend a lot of time working on the bash command line, and I’ve come to highly value the availability of my custom set of shortcuts, preferences, and tricks, right at my fingertips. You know, all the stuff that lives in .bashrc, .profile, .vimrc, .git, etc. I operate and develop across an array of servers, from my own to my clients, and it’s not always easy to reconfigure the same bash aliases every time I access a new server. As such, I decided to create a public list of the top aliases I use, and am making them available for anyone else to use as well.

Setup

There are a lot of various aliases and an infinite amount of variations possible. Because of this, we’re going to place our bash aliases in a separate file, that will exclusively contain aliases, called .bash_aliases. However, we need to be sure that the .bashrc file will load the file containing our aliases. To do this, simply open your .bashrc file in your preferred editor, and verify that the following code is in your file:
				
					if [ -e $HOME/.bash_aliases ]; then
    source $HOME/.bash_aliases
 fi
				
			
Now that you have confirmed that you can load your .bash_aliases file, let’s add the aliases to it! Here is the list of aliases that I use daily, and implement on all servers that I operate on:
Simply copy and paste the entire file into your .bash_aliases file, save, and exit, and you’re nearly ready to go! The final step is to refresh your bash environment by running source ~/.bashrc. Congratulations on installing new bash aliases for yourself, and enjoy experimenting with the shortcuts!

Automatic Install

If you’d like to streamline the process even further, run the following one-line command to automatically install the above bash aliases automatically: 

				
					 bash <(curl -Ss "https://gist.githubusercontent.com/andrewhenke/f4243b7974fc5dcce948df67c1d6f914/raw/d47552cad596d31075b5d1579a02c45dd8056acd/importaliases.sh")
				
			

After running the above command, you will see output similar to the following: 

				
					Bash Aliases file does not exist, proceeding
Bash Alias file configuration not found, adding support now.
Support added - creating aliases
Aliases Created
				
			

You’re now good to go! Enjoy your new shortcuts, and please suggest additional shortcuts to add if you find them useful! 

Share This :