Diving into MacOS
After spending nearly 15 years working with Windows and focusing the last 8 years spending most of my time on Linux, I have experienced MacOS for the first. By chance, my spouse happened to buy a new MacBook and gifted me her 2013 model. Of course, I still consider my Linux desktop to be my daily driver and keep Windows around for gaming needs, but over the past week Ive found myself using the MacBook more and more for things that dont require gaming specs or advanced dev tools.
Initial Thoughts
Before I move on to the technical aspects of my set-up, I want to take some time and express my thoughts on the overall OS.
As expected, the initial computer setup is breeze with Macs guided GUI installer.
The desktop itself reminds me of GNOME more than anything else Ive seen - even Pantheon from ElementaryOS, which people common refer to as the closest Linux distro to MacOS. The desktop toolbar is great and far surpasses the utility of the GNOME toolbar due to the fact that the extensions and icons actually work. I launch MacOS and immediately see my shortcuts for Tresorit, Bitwarden, and Mullvad pop up as the computer loads.
Even further, the app dock is very useful and will be yet another familiarity for GNOME users. I know many people like panels instead of docks, but Ive always found docks to have a more pleasing UI. However, I had to disable the Show recent applications in Dock preference - I cant stand items taking up precious screen space if Im not currently using them. On that same note, its taking me some time to get use to the fact that I have to manually quit an app or else it will still stay open/active in the dock, even if Ive closed out all windows for that app (e.g. Firefox).
Overall, Im having a lot of fun and for users who spend a large majority of their time performing basic tasks like web browsing, writing, watching media, etc., MacOS is a fantastic option.
The rest of this post explains the technicalities of how I set up my CLI environment to make me feel more at-home, similar to the environments I set up on Fedora, Ubuntu, etc.
Making it Feel Like Home
If youre someone who uses Linux primarily, no doubt your first thought when booting MacOS will be the same as mine was: Where is the terminal and how do I set up my favorite utilities?
Luckily, MacOS hasnt completely hidden away the development tools from the average user. You can easily find the Terminal app in the Launchpad area, but its probably not what youre used to. I was surprised (and happy) to see that the default shell is zsh
, the shell I use on all of my Linux distros. However, the commands are not the same - even the ones you may think are native to the shell. Commands like dir
do not exist, so other native commands like ls -la
or pwd
are more useful here.
With only a few minutes of installing and tweaking a few packages, I was able to recreate a terminal environment that I feel very comfortable using. See the image below for a preview of the iTerm2 app with a split view between my MacOS desktop shell and an SSH session into my server.
Xcode
My first step was to search the web for any hints on how to get zsh
back up to the state I like, with extensions, themes, etc. My first step was to install the CLI tools for Xcode, Apples suite of development tools.
sudo xcode-select -r
sudo xcode-select --install
Homebrew
Next up is to install Homebrew, a nifty package manager for MacOS.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I ran into a permissions error when installing Homebrew:
Error: Failed to link all completions, docs and manpages:
Permission denied @ rb_file_s_symlink - (../../../Homebrew/completions/zsh/_brew, /usr/local/share/zsh/site-functions/_brew)
Failed during: /usr/local/bin/brew update --force --quiet
I found that the following permissions modification worked like a charm. However, I noted that some users online discussed the fact that this solution may not work if your system has multiple users who each use Homebrew.
sudo chown -R $(whoami) $(brew --prefix)/*
Next up is to ensure Homebrew is updated and cleaned.
brew update
brew cleanup
iTerm2
Now that Ive installed the basic utilities for development, I moved onto installing iTerm2, a much better terminal than the default.
brew install --cask iterm2
I also used the Make iTerm2 Default Term
and Install Shell Integration
options in the iTerm2 application menu to make sure I dont run into any issues later on with different terminals.
We will also install zsh
so we can use it in iTerm2.
brew install zsh
Oh-My-Zsh
Ive shown the great aspects of Oh My Zsh in other blog posts, so Ill skip over that speech for now. Simply install it and run an update:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)
omz update
Finally, restart the iTerm2 application to ensure all changes go into effect.
Oh-My-Zsh Themes
Lets change the theme of the terminal to make it a little more friendly.
open ~/.zshrc
The third section of this file should contain a line like the code below. Change that theme to any theme you want, save the file, and exit.
ZSH_THEME=af-magic
After changing the .zshrc
file, youll need to source it so the system can apply the changes:
source ~/.zshrc
Oh-My-Zsh Plugins
Of course, my customization of zsh
would not be complete without zsh-autosuggestions. This will bring up commands youve run in the past as you type them. For example, if youve run ssh user@192.168.1.99
before, the terminal will show this command as soon as you start typing it (e.g. zsh u
) and you can hit the right arrow to autocomplete the command.
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
open ~/.zshrc
# Scroll down the script and edit this line to add zsh-autosuggestions
plugins=(git zsh-autosuggestions)
source ~/.zshrc