Setting up a new mac

Sun 20 October 2013 — Filed under notes; tags: mac

These are my notes that I took while setting up a macbook Air near the end of 2013, with incremental updates when I remember to add them.

Oct 2014
increment versions of various applications, update for Yoesmite

First applications

Developer tools

Pretty much the first thing any mac needs is the command line tools. These can be installed from within the Xcode application, available as a download from the Apple app store (https://developer.apple.com/xcode/downloads/). Note that this requires an apple id, even though the download is free. Once Xcode is installed, install the command line tools via the Xcode preferences: http://slashusr.wordpress.com/2012/07/27/os-x-mountain-lion-need-to-reinstall-xcode-command-line-tools/

Edit: there appears to be another way to install the developer tools that does not require an apple ID - just run the following command:

xcode-select --install

Looks like you can even agree to the license from the command line using

sudo xcodebuild -license

See http://apple.stackexchange.com/questions/88535/how-to-download-the-command-line-tools-for-xcode-without-the-downloads-for-devel

X11

Download and install Xquartz http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.7.dmg

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

Others

system-level configuration

turn off spelling autocorrect

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

fix scroll direction

System Preferences –> Trackpad –> Scroll & Zoom –> unselect "scroll direction: natural"

turn off spaces key shortcuts

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

ssh

Copy my default private key.

homebrew

Be bloody, bold, and resolute:

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

Had to fix permissions:

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

stuff installed using homebrew

brew install aspell && \
brew install autojump && \
brew install gcc && \
brew install git && \
brew install gpg && \
brew install graphviz && \
brew install htop-osx && \
brew install latex2rtf && \
brew install pandoc && \
brew install readline && \
brew install tmux && \
brew install tree && \
brew install wget && \
brew install zsh

zsh

Install zsh with Homebrew above

Note that zsh files are in Dropbox/zsh

Change shell to zsh

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

cat > .zshrc <<EOF
export USR_ZSH_INITDIR=~/Dropbox/zsh
. ~/Dropbox/zsh/zshrc
EOF

git

git config --global user.name "Noah Hoffman"
git config --global user.email noah.hoffman@gmail.com

iTerm2 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"

Preferences –> Profiles –> Colors –> Load Presets –> Light Background

emacs

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

http://emacsformacosx.com/emacs-builds/Emacs-24.3-universal-10.6.8.dmg

Check out my .emacs.d

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

python

Doesn't work out so well using homebrew, so let's install from source. Note that we did install readline with homebrew above.

Here's a nice reference: http://arvinderkang.com/2012/07/06/a-virtualized-python-setup-on-os-x-lion/

To remove all user-installed packages:

rm -r /usr/local/lib/python2.7/site-packages
mkdir -p ~/src
cd ~/src && \
wget http://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz && \
tar -xf Python-2.7.9.tgz && \
cd Python-2.7.9 && \
export LDFLAGS=-L/usr/local/opt/readline/lib && \
export CPPFLAGS=-I/usr/local/opt/readline/include && \
./configure && make && make install

Note that installation does not require sudo because now I own /usr/local according to homebrew's preferences.

Install pip (see http://www.pip-installer.org/en/latest/installing.html)

(Beginning with pip v1.5.1, get-pip.py provides setuptools and no longer requires setuptools to be installed first.)

cd ~/src
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
chmod +x get-pip.py
./get-pip.py --force-reinstall

Even better: starting with python 2.7.9, you can bootstrap install pip directly from the standard library:

python -m ensurepip --upgrade

And install some python packages. Some of these packages take a while to compile, and it's nice to save compiled versions of wheels so that they can be included in a virtualenv - the bioy package includes a script that help set this up. First, we'll need some requirements.

cd ~/src
wget -N https://raw.githubusercontent.com/jorgenschaefer/elpy/master/requirements.txt
cat >> requirements.txt <<EOF
numpy
pandas
csvkit
pep8
autopep8
# pygraphviz
reportlab
jinja2
EOF

Now create the wheels for these packages and save them in a system-level directory.

cd ~/src
git clone git@github.com:nhoffman/bioy.git
bioy/dev/build_wheels.sh --wheelstreet /usr/local/share/python/wheels --requirements requirements.txt

Now these packages can be quickly be installed to the system or a virtualenv using these wheels:

pip install --use-wheel --find-links=/usr/local/share/python/wheels/2.7.8 -r requirements.txt

scons doesn't work with pip

cd ~/src
wget -N http://prdownloads.sourceforge.net/scons/scons-2.3.4.tar.gz && \
tar -xf scons-2.3.4.tar.gz && \
cd scons-2.3.4 && \
python setup.py install

ansible

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

R

cd ~/src
wget http://cran.fhcrc.org/bin/macosx/R-3.1.1-mavericks.pkg && \
sudo installer -pkg R-3.1.1-mavericks.pkg -target /
sudo 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

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

Edit 11/2014: updated versions for yosemite

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

wkhtmltopdf

cd ~/src
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'