Setup after clean install of El Capitan

Mon 02 November 2015 — Filed under notes; tags: mac

I had enough issues after updating to El Capitan (the inability to save my wifi password in the system keychain was the tipping point) that I decided to perform a clean install. Here are some notes.

First applications

Developer tools

Pretty much the first thing any mac needs is the command line tools. This can be done from the command line:

xcode-select --install

X11

Download and install Xquartz:

cd ~/Downloads
wget http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.8.dmg
open XQuartz-2.7.8.dmg
sudo installer -pkg /Volumes/XQuartz-2.7.8/XQuartz.pkg -target /

Note for next time: might be worth trying to use homebrew.

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

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

Others

system-level configuration

turn off spelling autocorrect

System Preferences –> Language & Text –> Text tab –> unselect "Correct spelling automatically"

turn off spaces key shortcuts

System Preferences –> Keyboard –> Keyboard Shortcuts –> unselect C+{<-,->}

homebrew

Note that El Capitan introduced System Integrity Protection (SIP), which may need to be temporarily disabled during homebrew installation. See https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md

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

If it becomes necessary to fix permissions:

sudo chown -R $(whoami) /usr/local

packages installed using homebrew

brew install homebrew/dupes/tcl-tk && \
brew install aspell && \
brew install autojump && \
brew install berkeley-db4 && \
brew install gcc && \
brew install git && \
brew install gpg && \
brew install graphviz && \
brew install htop-osx && \
brew install latex2rtf && \
brew install openssh && \
brew install pandoc && \
brew install pkg-config && \
brew install readline && \
brew install sqlite && \
brew install tmux && \
brew install tree && \
brew install wget && \
brew install zsh

homebrew cask

Command line installer for desktop applications. See https://caskroom.github.io

brew tap caskroom/cask

Install some applications

brew cask install java

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 above

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

cat > ~/.zshenv <<EOF
. ~/Dropbox/zsh/zstartup
EOF

ssh

After installing homebrew's openssh on El Capitan, ssh-agent no longer seemed to work (in the sense that after using ssh-add to cache a passphrase, I still got a system prompt when trying to ssh). This seemed to be fixed by the instructions I found at the url below (my version is functionally the same but uses PlistBuddy to edit the plist):

https://coderwall.com/p/qdwcpg/using-the-latest-ssh-from-homebrew-on-osx

update /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist

sudo /usr/libexec/PlistBuddy /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist<<EOF
Delete :ProgramArguments
Add :ProgramArguments array
Add :ProgramArguments: string /usr/local/bin/ssh-agent
Add :ProgramArguments: string -D
Add :ProgramArguments: string -t 1d
Save
Exit
EOF

This should change the original value of ProgramArguments:

<key>ProgramArguments</key>
<array>
	<string>/usr/bin/ssh-agent</string>
	<string>-l</string>
</array>

to

<key>ProgramArguments</key>
<array>
	<string>/usr/local/bin/ssh-agent</string>
	<string>-D</string>
	<string>-t 1d</string>
</array>

Now restart the service

launchctl unload /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist
launchctl load -w /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist
launchctl start org.openbsd.ssh-agent

create $ZSH_INITDIR/ssh-ask-keychain (called from start_ssh_agent.zsh)

cat ~/Dropbox/zsh/ssh-ask-keychain

create $ZSH_INITDIR/start_ssh_agent.zsh

(either as a file sourced from .zshrc, or as a code block in a login script)

cat ~/Dropbox/zsh/ssh_environ.zsh

git

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

emacs

Install emacs24 binary from http://emacsformacosx.com/

http://emacsformacosx.com/emacs-builds/Emacs-24.5-1-universal.dmg

Check out my .emacs.d

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

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 (installed above).

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 homebrew/python/numpy

Install some other packages to the system using pip.

For elpy:

pip install -r <(curl https://raw.githubusercontent.com/jorgenschaefer/elpy/master/requirements.txt)

ansible

sudo mkdir /usr/share/ansible
sudo chown -R $(whoami) /usr/share/ansible
pip install ansible

Others

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

R

Really doubling down on homebrew this time around:

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

sshfs

Provided by the project http://osxfuse.github.io/ - the links below are for binaries provided as installers.

cd ~/Downloads
wget http://sourceforge.net/projects/osxfuse/files/osxfuse-2.8.2/osxfuse-2.8.2.dmg
wget https://github.com/osxfuse/sshfs/releases/download/osxfuse-sshfs-2.5.0/sshfs-2.5.0.pkg

wkhtmltopdf

cd ~/Downloads
wget 'http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf.dmg'
open wkhtmltopdf.dmg
cp -r /Volumes/wkhtmltopdf/wkhtmltopdf.app /Applications

Now create an alias:

alias wkhtmltopdf='/Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf'