Setting up a new Mac (Sierra)

Thu 05 January 2017 — Filed under notes; tags: mac
  • Edit 2017-01-09: provide upgrade path to Pulse Secure client v5.1

This post describes the steps that I followed to set up a new mac running MacOS Sierra (10.12.2), in as close to the order in which I did things as I could reproduce. The primary purpose is to document what I did for when I perform a clean install of other machines; hopefully others will also find it useful.

This time around I really went all in on homebrew: I used homebrew to install not only command line programs and languages (python, R), but also as many desktop apps as I could (Chrome, x11) that would otherwise have been installed manually by hunting down an installer. When it wasn't entirely clear (to me) whether there might be some advantage of getting a program from another project (Emacs, Postgres.app), I did it the old fashioned way.

Somewhat glossed over here are manual steps used to transfer non-public dotfiles, credentials, etc. Here's a partial list of files and directories that I copied directly from my old laptop:

It's interesting that all none of these steps require an Apple ID - usually I sign in first thing, but this time I held off.

tar -cf dotfiles.tar .Xmodmap .gitconfig .gnupg .pypirc .ssh

system settings

turn off spelling autocorrect

System Preferences --> Keyboard --> Text tab --> unselect "Correct spelling automatically" and others

unmap Control + left,right

I use Control plus the left and right arrow keys to move between windows in emacs and tmux.

System Preferences --> Keyboard --> Shortcuts --> uncheck mission control: move left/right a space

First applications

iTerm2

Update a few settings.

Preferences –> Profiles –> Keys and do these things:

  • select "Left/right option key acts as": +Esc
  • + –> Keyboard shortcut "OPT+<left arrow>": Send Escape sequence "b"
  • + –> Keyboard shortcut "OPT+<right arrow>": Send Escape sequence "f"

Default appearance:

  • Preferences –> Profiles –> Colors –> Load Presets –> Light Background
  • Preferences –> Profiles –> Text –> Change Font –> 14 point

Dropbox

Install from website

Developer tools

This can be done from the command line:

xcode-select --install

Junos pulse VPN client

There are some reports of version 5.1 being broken in Sierra. At the time I'm writing this, my institution provides 5.1.9 (61653), which is indeed broken. The internet helpfully provides a link to an older version (we're trusting the University of South Florida, here): https://www.net.usf.edu/vpn/MacOS/JunosPulse.dmg

Installing this, and then running the updater provides 5.1.10 (61733), which seems to work.

Instructions for UW are here: https://networks.uwmedicine.org/content/sslvpn-frequently-asked-questions-14

Microsoft Office 2016

The initial version of Excel (15.11) crashed on startup as widely reported - this was fixed by updating to a version (15.29) provided by Microsoft:

https://support.microsoft.com/en-us/kb/3187505

Others

homebrew

Homebrew no longer requires user-ownership of /usr/local, so things are pretty easy now:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor

Some packages I'll need off the bat to do just about anything

brew install git
brew install wget

A number of packages are installed in the context of other applications; here are additional packages that I know I'll use.

brew install autojump && \
brew install gcc && \
brew install graphviz && \
brew install htop-osx && \
brew install latex2rtf && \
brew install pandoc && \
brew install tmux && \
brew install tree

Note other packages installed in other sections as well.

X11

install Xquartz

brew install Caskroom/cask/xquartz

X11 key bindings so that the option key is used for Meta..

cat > ~/.Xmodmap <<EOF
clear Mod1
clear Mod2
keycode 63 = Mode_switch
keycode 66 = Meta_L
add Mod1 = Meta_L
add Mod2 = Mode_switch
EOF

Desktop apps using Cask

Homebrew installs desktop apps too!

brew cask install google-chrome
brew cask install java
brew cask install mactex
brew cask install texmaker

homebrew API token

Apparently lots of requests to GutHub via homebrew can hit a rate limit. There's a higher limit if you create an API token. See https://gist.github.com/christopheranderton/8644743

Here's the url for the token creation dialog:

https://github.com/settings/tokens/new?scopes=&description=Homebrew

Make sure that all 'scopes' are unchecked. Once you generate the token, add to your shell profile:

export HOMEBREW_GITHUB_API_TOKEN=token_here

zsh

Install zsh with Homebrew

brew install zsh

Change shell to zsh

sudo -s
echo /usr/local/bin/zsh >> /etc/shells
exit
chsh -s /usr/local/bin/zsh $USER

zsh init files are in Dropbox/zsh. ~/.zshenv contains the following:

for pth in $HOME/Dropbox $HOME/src $HOME; do
    if [[ -f $pth/zsh/zstartup ]]; then
	. $pth/zsh/zstartup
	break
    fi
done

git

git config --global user.name "My Name"
git config --global user.email me@email.com

python

Use homebrew - see https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md

Run brew info python for required and optional dependencies

for pkg in sphinx-doc pkg-config readline sqlite homebrew/dupes/tcl-tk berkeley-db4; do brew install $pkg; done
brew install python --with-berkeley-db4 --with-tcl-tk
brew linkapps python
pip install -U pip
pip install -U setuptools
pip install -U virtualenv

Install some python packages using homebrew - these are time consuming to install otherwise.

brew install numpy

And a few packages that I usually like to have around.

Note that scons wants to install man pages to /usr/local/man, which is owned by root. You'll need to do this first:

sudo mkdir -p /usr/local/man
sudo sudo chown $(whoami) /usr/local/man

Now install the actual packages:

pip install ansible
pip install csvkit
pip install reportlab
pip install scons
pip install jinja2

Also install python3

brew install python3 --with-tcl-tk

emacs

Install latest emacs binary (25.1) from http://emacsformacosx.com/

Emacs needs a few homebrew packages

brew install libressl
brew install aspell
brew install gpg

Check out my .emacs.d and run setup scripts.

cd ~
git clone git@github.com:nhoffman/.emacs.d.git
cd .emacs.d
git submodule init
git submodule update
bin/venv.sh

For elpy:

pip install -r requirements.txt

R

Again, using homebrew.

brew tap homebrew/science
brew install r
R --slave << EOF
packages <- c("ape", "sqldf", "ROCR", "lattice", "RSQLite", "latticeExtra", "argparse", "data.table")
install.packages(packages, repos="http://cran.fhcrc.org/", dependencies=TRUE, clean=TRUE)
EOF

wkhtmltopdf

cd ~/Downloads
wget 'http://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_osx-cocoa-x86-64.pkg'

Use installer - binary is /usr/local/bin/wkhtmltopdf