A better use of command line aliases on macOS

Thanks for visiting my very first blog post. My name is Darren Parker and I’m a Co-Founder and Lead Developer at Digital Profile. Lets jump straight into things.

I want to share with you how I make use of aliases on command line or better said, how I don’t make use of aliases.

We all use these clever little things to improve our productivity and they have become an essential part of a developers workflow. So awhile ago I begun thinking about a better way of sharing aliases between multiple machines and teams of individuals.

Its rather simple how I achieved this… essentially I don’t use aliases and instead I create seperate bash scripts named as the alias would be that contain the commands I wish to run and store them in a git repository. I then reference the folder of this repository in my global path.

By doing this, these scripts become available to me anywhere on command line and are referenced just like any other alias with a few additional pro’s… changes to the scripts or their names do not require me to restart my terminal and I can create additional scripts that are instantly available to me again without restarting the terminal or opening a new window.

Let me show you how this is done and why it can be very useful for teams.

Step 1

Create a GitHub repository for your scripts. I’ve called mine “goto”. Its a generic name I use to store my scripts and other things like IDE configurations (more on interesting things here in another post coming soon).

Step 2

Pull down this repository onto your local machine.

git clone git@github.com:DMParker2888/goto.git goto

Step 3

Open this repository in your IDE and create a folder to store all of your scripts (aliases). Maybe even call this folder “aliases” if you like.

Step 4

Add this folder to your global path and restart your terminal. This will be the only time you have to do so.

export PATH=$PATH:$HOME/path/to/repository/aliases

Step 5

Return to your IDE and create a file in this folder with a name you wish to act as your alias, in this example I will name this “do-hosts-show” and it will contain the command to be executed. This is your first script.

Keeping it simple for this example


Open your terminal and type “do-” and tab you will see that the script can be referenced and run just like an alias.

If you make changes to this script or add more (even via “git pull”) you won’t have to restart the terminal again. These will be instantly available to you from anywhere.

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
## localhost broadcasthost
::1 localhost


As you can see this is a very simple way of dealing with commands and an even easier way of sharing with teams.

Imagine the scenario where you have a team who are all responsible for code deployments (this is a dangerous example I know but you catch my drift) and this is done via command line.

You can essentially create a script for this, ask your team to do a “git pull” and you have now ensured everyone has the latest deployment procedures which can then be run in their current terminal without a restart or new window.


In Step 5 you can see that I prefixed my alias with “do-”, this I recommend as it helps identify which are your scripts and with tab you can see a list of all that are available to you.

Thanks for reading my very first blog post, I only hope it can be of help to you so please provide feedback.

I care a lot about creating simple workflows and anything that can increase productivity in teams especially whilst leading towards developer happiness so be sure to read more posts in future about things I wish to share.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.