Setup a New Mac

I recently set up a new mac. Here is a list of my favorite things to do to properly setup macOS for scientific work.

Basic setup

First things first, to install pretty much anything you need Xcode. Go grab it from the Mac AppStore. You’ll need the “command-line tools” as well, but that will be installed automatically by the next step. If you want to do it manually, type this in a terminal:

xcode-select --install

This includes all the useful open-source tools Unix developers expect, like git, clang, and more. You’ll have to agree to the license. If this ever breaks, the following line will fix it:

xcode-select --reset
sudo xcodebuild -license

Next, install HomeBrew, this is the my favorite package manager for Macs.

/usr/bin/ruby -e "$(curl -fsSL"

(This may change in a future macOS release when scripting languages are removed?)

Brew installs

I am providing a brew bundle file here. It can be installed by running brew bundle. See the docs here. Or see a nice blog post here for a quick introduction to bundles.

tap "homebrew/bundle"       # First line of a bundle
tap "homebrew/cask"         # Not needed on command line
tap "homebrew/cask-fonts"   # Just needed for font casks below
tap "homebrew/core"         # Not needed on command line

# Building tools
brew "boost"        # C++ library
brew "ccache"       # Faster builds by caching
brew "cmake"        # Build software projects
brew "ninja"        # Replacement for make
brew "doxygen"      # Doxygen generates C++ documentation
brew "pre-commit"   # Allows pre-commit hooks to be installed and managed

# General utilities
brew "colordiff"    # More colorful diffs outside of git
brew "coreutils"    # Basic stuff with a g prefix
brew "gnu-sed"      # Adds the gsed command, more powerful than BSD sed
brew "openssl"      # Security stuff
brew "git"          # The latest version of git instead of Apple's older one
brew "htop"         # htop is better than top for checking processes
brew "tree"         # tree is nice for looking at directories
brew "wget"         # Mac's have curl by default, but not wget
brew "bash"         # Bash 5 instead of 3, in case you need it
brew "rename"       # Rename files utility
brew "clang-format" # Format C++ files

# Personal customization options
brew "fish"         # My favorite shell. Might move to zsh when macOS does, though
brew "lmod"         # See my posts on lmod
brew "macvim"       # VI for macOS, with mvim graphical interface too
brew "interactive-rebase-tool" # Run git config --global sequence.editor interactive-rebase-tool

# Programming languages
brew "python"       # Python 3
brew "numpy"        # Now is Python3 only (numpy@1.16 is for python@2)
brew "go"           # Used by hugo, can be useful to have
brew "node"         # Javascript (for gitbooks, etc)
brew "ruby"         # Just to be extra sure the system Ruby never gets modified
brew "rbenv"        # Use this for ruby
brew "rust"         # Was trying out mdbook

# Packages
brew "hugo"         # Fast website generator
brew "pandoc"       # Convert between document formats
brew "qt"           # The #1 graphics library for C++ and Python
brew "root"         # High Energy Physics toolkit

brew "libsodium"    # Have no idea why I needed this

# Fonts
cask "font-hack-nerd-font"
cask "font-sourcecodepro-nerd-font"

# Core
cask "iterm2"       # A great terminal
cask "java"         # Meh. What can I say?
cask "mactex"       # LaTeX. Huge.
cask "miniconda"    # Nice way to get a system Conda install

# Programs
cask "google-chome" # Since once and a while a site doesn't work with Safari
cask "gimp"         # Photo editor
cask "blender"      # The 3D application

# Editors
cask "macdown"      # Nice Markdown
cask "texstudio"    # Nice IDE for LaTeX
cask "meld"         # Compare files graphically.

# Daemons
cask "docker"       # Allows running and building docker images
cask "dropbox"      # The cloud
cask "synergy"      # Share a mouse and keyboard between computers. Free option is okay.

# Chat
cask "mattermost"
cask "skype"
cask "slack"

If you want to install these by hand, just change brew "xxx" to brew install xxx on the command line, and cask "xxx" to brew install cask xxx. You shouldn’t need to “tap” the casks, though if you want the fonts I’m using, you will want to either tap it or run .

Anything else that is not open-source, or is hard to build, is still installable by homebrew as a cask. Plus, you can upgrade casks, so this is slightly better than installing the package by hand. (Casks are homebrew formula that just wrap an existing installer).



If you want to use fish, add fish to /etc/shells and then run:

chsh -s /usr/local/bin/fish

Install fisher:

curl --create-dirs -sLo ~/.config/fish/functions/

This works best when you use the extended fonts in your terminal, and then run:

set -g theme_nerd_fonts yes
fisher install oh-my-fish/theme-bobthefish

Jupyterlab and key Python utilities

Since you can run kernels from Conda in any JupyterLab install, I like to install it directly into the Homebrew Python 3 instance - note this can be hard to upgrade; there is work on a brew formula for jupyterlab. Run this:

python3 -m pip install jupyterlab pyforest plumbum

Now, make sure you install nb_conda_kernels into your conda environments, and you’ll be able to see them without activating the environments!

Quality of life

I like to change capslock into escape, which is in keyboard settings, and must be done per-keyboard.


It is important to have installed macvim from brew directly, and not the cask, or otherwise the vi command will not be changed to the new vim. Here is my vimrc, which includes directions. I used to use the ultimate VIM package, but this is much more flexible; still adjusting to fill in gaps. Things will break if you use the system vim; you should at least run:

git config --global core.editor $(which vim)

to make sure you do not open the old vim instead when committing with git.

" This part now automatic:
"   Start by installing Vim Plug:
"   After changing the Plugs or adding this fill run :PlugInstall
" Ror youcompleteme, you then need to go to the directory and
" run python --all (or list parts) to build it.
" Use git config --global core.editor $(which vim) to ensure you do
" not run system VIM!
" Based on searches from

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC

" Vim-Plug
call plug#begin('~/.vim/plugged')

" Nicer defaults
Plug 'tpope/vim-sensible'

" Nicer searching
Plug 'haya14busa/is.vim'

" Nicer status bar
Plug 'vim-airline/vim-airline'

" Code completer for VIM
" Requires brew install vim or macvim
Plug 'valloric/youcompleteme'

" Github marks in the gutter
Plug 'airblade/vim-gitgutter'

" File browser
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'

" Support EditorConfig
Plug 'editorconfig/editorconfig-vim'

call plug#end()

" Nicer powerline
let g:airline_powerline_fonts = 1

" Nerdtree customize
map <C-n> :NERDTreeToggle<CR>

" Extra customization
set mouse=a
set spell

" Needed to use is.vim
:set hlsearch

" MacVim needs a nicer font too
set guifont=SauceCodePro\ Nerd\ Font

" Reasonable indentations
set expandtab tabstop=4 shiftwidth=4 softtabstop=4

autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
autocmd Filetype ruby setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd Filetype html setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd Filetype markdown setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd Filetype css setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd Filetype scss setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
comments powered by Disqus