Macbook Setup

August 17, 2017   

When I got my new computer for work, I realized I had to reinstall and set up everything that had taken me years to curate on my old computer. And … turns out I have a really custom setup. Here are the steps I took to install everything I need to get started.

Personal web and input preferences

  • Google Chrome Browser
  • ~Quicksilver~ - deprecated in favor of Spotlight Search
  • Add Russian language for input sources
  • Remove all Apple software from dock except “System Preferences”

Development environment

  • Git/XCode (type git at the Terminal and mac OS Sierra knows you’re a coder and installs tools for you)

(Interactive) Python Debugger Settings

When I can, I prefer to use the interactive Python debugger (ipdb) over the built-in pdb. For example, when debugging dobby instead of running python -m pdb dobby/cli.py, I’ll run python -m ipdb dobby.cli.py. To make pdb especially useful, I really like using these aliases which are super helpful to navigate the stack trace and print the variables you have around.

# Ned's .pdbrc from https://stackoverflow.com/questions/1623039/python-debugging-tips

# Print a dictionary, sorted. %1 is the dict, %2 is the prefix for the names.
alias p_ for k in sorted(%1.keys()): print "%s%-15s= %-80.80s" % ("%2",k,repr(%1[k]))

# Print the instance variables of a thing.
alias pi p_ %1.__dict__ %1.

# Print the instance variables of self.
alias ps pi self

# Print the locals.
alias pl p_ locals() local:

# Next and list, and step and list.
alias nl n;;l
alias sl s;;l

# Short cuts for walking up and down the stack
alias uu u;;u
alias uuu u;;u;;u
alias uuuu u;;u;;u;;u
alias uuuuu u;;u;;u;;u;;u
alias dd d;;d
alias ddd d;;d;;d
alias dddd d;;d;;d;;d
alias ddddd d;;d;;d;;d;;d

Copy the above text into the clipboard and paste it into your ~/.pdbrc file with one command:

pbpaste > ~/.pdbrc

pbpaste stands for “Pasteboard” paste, which takes the contents of your clipboard so you can use it on the command line. There’s also pbcopy which you can pipe stdout into the clipboard, e.g. to paste your ~/.pdbrc file:

cat ~/.pdbrc | pbcopy

Integrated development environment (IDE)

PyCharm is a fantastic IDE for Python developers. It’s excellent in part because it leverages the entire JetBrains ecosystem, which has great plugins e.g. for Markdown and .gitignore files.

Plugins:

Terminal preferences

# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"

... more options ...

# Preferred editor for local and remote sessions
# Changed to `emacs`
if [[ -n $SSH_CONNECTION ]]; then
  export EDITOR='vim'
else
  export EDITOR='mvim'
fi

... more options ...

# ssh
export SSH_KEY_PATH="~/.ssh/rsa_id" 

Add alias for Triton Supercomputing Cluster (TSCC):

# Alias to Triton Supercomputing Cluster (TSCC)
alias tscc="ssh obotvinnik@tscc-login2.sdsc.edu"

Never use vi/vim:

# >:)
alias vim=emacs
alias vi=emacs

ssh keys

cat .ssh/id_rsa.pub | ssh obotvinnik@tscc.sdsc.edu 'cat >> .ssh/authorized_keys'

Mac OS Terminal program settings

Here are my personal preferences for setting up the terminal in Mac OS.

Side Note: Mac OS Sierra’s high contrast I-beam is on point. I’ve lost that cursor so many times in El Capitan.

Python (Anaconda Distribution)

Installing scientific Python packages from scratch is a pain and you will lose weeks of your life setting up your LD_LIBRARY_PATH and hunting down Math Kernel Libraries (if you’re really interested, check out this blog post). Enter the Anaconda Python Distribution, which makes installing math-heavy python a total breeze.

  • Anaconda Python
    • Make sure to copy the lines added to ~/.bash_profile to ~/.zshrc since Anaconda doesn’t know you use oh-my-zsh
    • Make separate environments for each github repo
    • Add kernels to Jupyter notebooks
    • For each environment, need to do:
source activate kvector-env
conda install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python 3.6 (kvector-env)"

Homebrew

Homebrew is the “missing package manager” for Mac OS. It lets you install software from the command line in an sudo apt-get-like way like you can do in Linux systems! It’s super useful.

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

Here are all the programs I installed. For all of them, you install them with brew install commandname, e.g. brew install hub for the command hub.

  • hub which a command line wrapper for git that lets you do pull requests and such from the command line!
  • Add GitHub access token token for command line access so you can do hub pull-request on the command line. To save this personal access token securely so you’ll never have to type in your password for the command line again, you need to do two things:

    1. Tell the command line git to use the credential-osxkeychain as a place to look for passwords.
  ➜  manuscript git:(master) git config --global credential.helper osxkeychain
  1. Push to a repository, using your username (mine is olgabot) and the token as th1e password. From now on, your computer should remember your token
  ➜  manuscript git:(master) git push -u origin master   Username for 'https://github.com': olgabot
  Password for 'https://olgabot@github.com': 
  Counting objects: 636, done.
  Delta compression using up to 8 threads.
  Compressing objects: 100% (273/273), done.
  Writing objects: 100% (636/636), 174.08 KiB | 0 bytes/s, done.
  Total 636 (delta 350), reused 636 (delta 350)
  remote: Resolving deltas: 100% (350/350), done.
  To https://github.com/singlecell-batches/manuscript.git
  * [new branch]      master -> master
  Branch master set up to track remote branch master from origin.
  1. Double check that it worked. Open “Keychain” and check that https://github.com is listed a website (the https is important)
  • brew install git-lfs for git large file storage
  • tree to view directory trees from the command line
  • watch to rerun commands forever, e.g. use watch --interval 1 ls to rerun ls every second so you can see files get updated while some process is running.
  • hg for Mercurial source code repositories
  • cmake for software that uses cmake instead of Make to build stuff
  • gifsicle for making Gifs on the command line
  • imagemagick for manipulating image types on the command line
  • ruby for managing Ruby Gems such as Jekyll and Travis-CI. Plus there’s a nice gist tool for creating gists from the command line Then …
    • brew install gem
    • brew install jekyll
    • brew install travis
    • brew install gist - nice tool for creating gists from files via the command line

Folder organization

I decided to keep all my github repositories in my home directory, under ~/code.

  • Downloaded GitHub repos from grad school that I’m still working on

Other software

Here are some other software packages that I find very useful to use on my Mac.

  • Caffeine - Turn off the screen dimming on your mac - keep it “awake” :)
  • Toggl for time tracking so I know how long I spend on projects. This was especially useful for seeing how long formatting my dissertation took
  • VLC - Watch videos in something other than .mov or .mp4 format
  • Flux - Dim the blue light in your screen at night so you sleep better


comments powered by Disqus