Jack Keller

#BLACKLIVESMATTER

As a human being, and developer, I stand with the Black Lives Matter Movement and you should too.

Terminal Velociraptor

Okay, this really isn’t about dinosaurs, I just like to keep things in sync to a ridiculous degree, so lemme talk about my ZSH!

 

Okay, we’re all pretty used to a similar/same workflow from machine to machine, and if you have just a single workstation … you’re golden!

But if you’re like me, you have a work machine, and a personal machine (both similar MBP’s in my case) and you would sort of like to have a consistent experience from machine to machine. So, keeping your dotfiles in a git repo can be a godsend. Now, I used to take that approach, but a few years ago, I transitioned to oh-my-zsh and customized it over time to suit my tastes. With a framework like this, you don’t want to touch the core repo, but they’re fresh, and because they love you (the end-user), they provide a nice folder called custom where you can add themes, functions, aliases, etceteras. The issue was, I was maintaining similarities between my machines when I didn’t have to.

So the logical approach is to take the custom folder and turn that into a repo on GitHub. Oh, yas! Now, here’s where a few issues began to creep in. I’d also like to keep my .zshrc in sync, so I moved that into the repo and did a simple symbolic link in my home directory. Oh, but wait, my usernames do not match, so how do I handle that in my .zshrc? Dang, I thought I had a great idea, but now it’ll fail on one of my machines when it comes to my $PATH.

host=$(hostname)
workmachine="YOUR-WORK-MACHINE-HOSTNAME"
if [["$host"=="$workmachine"]];then
  USER='YOUR-WORK-USERNAME'
else
  USER='YOUR-PERSONAL-USERNAME'
fi

Cool, now reference my username as $USER in the appropriate path declarations!

Is this foolproof? Not likely as I’m a huge fool, but I think I’m on the right path (or is it $PATH), anyway, what is your strategy on keeping your shell in sync?