Apple Silicon and Homebrew
Look, new, shiny Apple Silicon
Like a lot of folks in my field, I now have a Apple Silicon based system (in my case a MacBook Air that I am composing this post on). It’s nice and fast for what I am using it for, which is mostly email and web browsing with a little local personal dev work (like this web site). It’s basically a very nice iPad and a keyboard. :) It pairs up nicely with my existing 2019 Intel-based Mac Mini.
Keeping things portable
While I tend to type on Macs, I also have server environments that cover FreeBSD & Linux, so my personal environment tends to be rather portable, so the same script can run if need be on a Mac or FreeBSD/Linux (just need to account for the different locations per platform). Also to keep things sane, I use zsh on all of my systems (I made the switch several years before Apple made the change in macOS, LOL)
On my Macs, I use Homebrew to manage my command line (CLI) packages. A lot of these packages I use both here on my Mac’s and my servers. This includes for example:
- AWS CLI that I use to manage my AWS resources
- neofetch to display system information and usage when I log into one of my systems.
With Apple Silicon, which is a ARM based architecture, and with Apple increasing the system lockdown of
/usr/local, Homebrew made the decision with v3.x
to have packages for Apple Silicon install in
/opt/homebrew instead. Intel based Homebrew installs still install in
/usr/local for now) so no one has to account for both paths.
.zshrc I account for the discrepency by checking first if we are running macOS (Darwin), then what architecture (Apple Silicon is arm64, Intel is x86_64):
# If neofetch exists, run it. # macOS (brew) if [ "$(uname 2> /dev/null)" = "Darwin" ]; then if [ "$(uname -m 2> /dev/null)" = "arm64" ]; then if [ -e /opt/homebrew/bin/neofetch ]; then /opt/homebrew/bin/neofetch fi elif [ "$(uname -m 2> /dev/null)" = "x86_64" ]; then if [ -e /usr/local/bin/neofetch ]; then /usr/local/bin/neofetch fi fi fi
This allows for checks based on what platform this system is running under.