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.
git
at the Terminal and mac OS Sierra knows you’re a coder
and installs tools for you)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
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:
~/.zshrc
:
plugins=(git osx python)
# 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
keysssh
keyssh
key to GitHubcat .ssh/id_rsa.pub | ssh obotvinnik@tscc.sdsc.edu 'cat >> .ssh/authorized_keys'
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.
option
as the Meta
key for emacs
: Preferences > Settings > Keyboard > Use option as meta keyInstalling 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.
~/.bash_profile
to ~/.zshrc
since Anaconda doesn’t know you use oh-my-zsh
source activate kvector-env
conda install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python 3.6 (kvector-env)"
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:
➜ manuscript git:(master) git config --global credential.helper osxkeychain
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.
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 lineI decided to keep all my github repositories in my home directory, under ~/code
.
Here are some other software packages that I find very useful to use on my Mac.