My fork of Robby Russel's Oh My Zsh is available here. I've made some customization:
.zshrcwith what we are going to talk about
- the minimalist-yet-informative John theme
LS_COLORSbased on trapd00r's
Most of the time, I'm working on my Macbook Air with OS X. I also have an old iMac running Ubuntu and the server this blog is running on is also Ubuntu. So setting up Oh My Zsh on both of them was one of the first things I did.
But as my
.zshrc was for OS X, I had a lot of annoying errors on Ubuntu...
What I did not want to do:
- Having to un/comment the lines between OS X and Ubuntu: it's stupid and as I'm using git it would eventually screw things up...
- Having to maintain two files: having to duplicate all the changes is cumbersome and prone to errors...
Comes out the solution I needed was pretty simple: I have to check if the OS running was OS X or Ubuntu. In Zsh language, it goes like that:
if [[ $OSTYPE =~ "darwin" ]]; then echo "Hi Surfer!" # Add your OS X configuration here elif [[ $OSTYPE == "linux-gnu" ]]; then echo "Hi Hacker!" # Add your Linux configuration here fi
The important part is
$OSTYPE =~ "darwin" - note the
=~, it means we check if
darwin. This way, it works with all the current versions of OS X, from Lion to Yosemite.
If you want to check for a specific version of OS X, you can use
$OSTYPE == "darwin14.0.0" for Yosemite.
You can checkout my own configuration line 76 in my
.zshrc as it might be helpful.
As I said, it's pretty basic but made my day when I found it.
Hope this helps! :)