OS Specific Bash Aliases Or Configs Using Conditions

Posted by Weston Ganger on December 21, 2015

I usually keep all of my dotfiles in a repo and share them across all of my machine. So when I had a couple of Bash alias’ that were not working and environment variables that were different on my Macbook it was becoming a bit annoying.

So I started using OS conditionals inside my .bash_aliases and .bashrc files

if [[ $(echo $OSTYPE) == "linux-gnu" ]]; then
  # Linux
elif [[ $(echo $OSTYPE) == "darwin"* ]]; then
  # Mac OSX

Related External Links:

Posted in Linux and Tagged with bash osx linux 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts