Aaron Holbrook
I'm Aaron Holbrook: a web engineer, father, gamer and geek.

My solution to quickly syncing .bash_profile on multiple machines

You know that feeling when you’re setting up a brand new server and it’s not set up the way you’ve spent years tweaking it to be?

Nice and comfy customized .bash_profile, even got my <code><p class=ls command to show hidden files by default!" src="https://aaronjholbrook.com/wp-content/uploads/2013/01/11513-533-PM.png" width="710" height="446" srcset="https://i0.wp.com/aaronjholbrook.com/wp-content/uploads/2013/01/11513-533-PM.png?w=710&ssl=1 710w, https://i0.wp.com/aaronjholbrook.com/wp-content/uploads/2013/01/11513-533-PM.png?resize=300%2C188&ssl=1 300w" sizes="(max-width: 710px) 100vw, 710px" /> Nice and comfy customized .bash_profile, even got my ls command to show hidden files by default!

As opposed to the following (setting up a new linux box, not even ls works how I like it).

Default. Ugh - beat it with the .bash_profile stick please!

Default. Ugh – beat it with the .bash_profile stick please!

After taking a brief glance at alias.sh, I decided I wanted to be able to customize things just a little bit more to my liking.

I came up with the following workflow:

  1. Use GitHub to host a always-up-to-date published .bash_profile
  2. Use a TextExpander snippet to easily wget the .bash_profile from GitHub onto the new server
  3. [OPTIONAL] Keep my local work machine’s aliases separate from remote production machines by separating them out into a .bash_aliases file
  4. [OPTIONAL] One more TextExpander snippet for the .bash_aliases to make things easy

Step 1

I published out my files in a new repo on GitHub, titled tersely enough: dotfiles.

I went back and forth between GitHub and BitBucket, and even tried out BitBucket since they offer free private repositories, but unfortunately BitBucket’s URLs for the RAW files include the commit hash, which would be changing with each commit, rendering my TextExpander snippet useless.

So – because I need the RAW file URL to be unchanging, I went with GitHub, even though it means publicizing all my current aliases. Oh well – enjoy 🙂

So – this gets us a public published RAW url that will not change.


Step 2

I use the following command:

wget -q -O - "[email protected]" https://raw.github.com/AaronHolbrook/dotfiles/master/.bash_profile > ~/.bash_profile

and place it inside a TextExpander snippet with the shortcut of: dotfilespullprofile.

Step 3

For my personal use case, I prefer to have my command prompt styled and things like ls and stuff always the same, regardless of if I’m on my own machine or if I’m SSHed into a server. But there are certain aliases that shortcut me to some folders, however I don’t really want those aliases to be on the server (as it’d be pointless and confusing).

Thus, I separated my aliases into a separate file, which .bash_profile only pulls in if it exists:

if [ -f ~/.bash_aliases ]; then

. ~/.bash_aliases

Step 4

I use the following command to pull in the .bash_alias.

wget -q -O - "[email protected]" https://raw.github.com/AaronHolbrook/dotfiles/master/.bash_alias > ~/.bash_alias


And there you have it, a quick and dirty way to sync your always-up-to-date .bash_profile onto new machines!

  • OMGZ. So glad you posted this. Been trying to get ls to use ls -G by default forever.