I'm a die hard Linux user, but in November 2022, I had to use a Mac for some work. This document describes how I turned a vanilla install of the latest macOS into a powerful Unix workstation.
This is AFAIK the best package manager for Unix tools on macOS. Install it with:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
I've grown very fond of the kitty terminal. I believe it's the best terminal around, it even beats iTerm2 😃. It strikes a great balance between features (24 bit colours, Unicode, multiplexer, view pictures on remote servers, remote server clipboard integration++) and speed. Install it with:
$ curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin
Or else, I'll go seriously mad.
Head over to System preferences, then Keyboard and finally
Modifier Keys.
$ brew install git
I prefer the ZSH shell over BASH:
$ brew install zsh
$ brew install zsh-autosuggestions
$ brew install zsh-completions
$ brew install fzf
You should install a newer version of bash. Although I use ZSH for
my interactive shell, I still do lots of shell programming in
BASH. The version of bash that comes with macOS is very old,
3.2.57, so installing a newer bash with brew:
$ brew install bash
Verify that the new version is correctly installed and available in your PATH by running:
$ bash --version
GNU bash, version 5.2.26(1)-release (aarch64-apple-darwin22.6.0)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
GNU coreutils, sed, awk, getopt and grep are superior to the
ancient BSD tools that ship with macOS.
$ brew install base64
$ brew install coreutils
$ brew install gawk
$ brew install gnu-getopt
$ brew install grep
$ brew install gsed
$ brew install procps-ng
Now, ensure that the GNU versions of these tools take precedence over the old BSD versions that macOS ships with. To do this, you must edit the settings file for your shell.
If you don't know which one you're using, type:
$ echo $SHELL
/bin/zsh
With that, you know which .bashrc of .zshrc to edit. Add the
following:
export PATH=\
/usr/local/bin:\
/usr/local/Cellar/gnu-sed/4.9/libexec/gnubin:\
/usr/local/opt/coreutils/libexec/gnubin:\
/usr/local/opt/gawk/bin:\
/usr/local/opt/gnu-getopt/bin:\
/usr/local/opt/grep/libexec/gnubin:\
/usr/local/opt/openjdk@11/bin:\
$PATH
As you can see from the above paths, gnused isn't packaged like the
others, and doesn't provide a bin directory outside the cellar.
After this change to your PATH variable, you must reload the settings:
$ source .bashrc # For BASH shells
$ source .zshrc # For ZSH shells
Alternatively, start a new terminal window.
$ brew install gnupg
$ brew install openjdk@11
Ensure this JDK's binaries are first in PATH, add these to ~/.zshrc
or ~/.bashrc:
export PATH=/usr/local/opt/openjdk@11/bin:$PATH
Installing jq allows you to query JSON documents, a bit like what XPath on XML files.
$ brew install jq
Installing json_xs lets you convert between YAML and JSON. For
instance, you can use this to do look ups in YAML documents using
jq. json_xs doesn't exist in Homebrew, but you should be able to
install it from CPAN using cpm (untested):
$ brew install cpm
$ cpm install JSON::XS
$ cpm install YAML::XS::LibYAML
My company uses Microsoft Teams, so that' the one to get.
Update 2022-11-22: Per told me Teams can also be installed with brew
like so:
$ brew install --cask microsoft-teams
Download the excellent Adobce Source Code Pro
font,
unzip it and drag and drop the files to the Font Book:
btop is my favourite resource monitor these days, install it with:
$ brew install btop
Install Emacs from emacsformacosx.com, this gives you a good, up to date Emacs build.
Note, this build doesn't provide native compilation (aka "gccemacs"), nor the non-blocking JSON processing done in this emacs-lsp fork.
Update 2022-11-25: It's also possible to get Emacs with brew. Note,
after testing this on a fresh Mac, I the --cask emacs
--with-native-comp --with-cocoa options didn't work, so had to just
issue the below command which gives a non-graphical Emacs (to get the
full package, use the emacsformacosx link above):
$ brew install emacs
$ brew install aspell
Your shiny macOS machine is now a good, modern Unix workstation with most of the same tools and versions as GNU/Linux distributions ship with.
Happy hacking!