I recently set up a new mac. Here is a list of my favorite things to do to properly setup macOS for scientific work.
First things first, to install pretty much anything you need Xcode. Go grab it from the Mac AppStore. You'll need the “command-line tools” as well, but that will be installed automatically by the next step. If you want to do it manually, type this in a terminal:
xcode-select --install sudo xcodebuild -license
This includes all the useful open-source tools Unix developers expect, like git, clang, and more. You'll have to agree to the license.
If this ever breaks (click to expand)
The following lines will fix problems if this breaks:
xcode-select --reset sudo xcodebuild -license
Next, install HomeBrew, this is the my favorite package manager for Macs.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
(This may change in a future macOS release when scripting languages are removed?)
If you want to install these by hand, just change
brew "xxx" to
brew install xxx on the command line, and
cask "xxx" to
brew install cask xxx.
You shouldn't need to “tap” the casks, though if you want the fonts I'm using, you will want to either tap it or run .
Anything else that is not open-source, or is hard to build, is still installable by homebrew as a cask. Plus, you can upgrade casks, so this is slightly better than installing the package by hand. (Casks are homebrew formula that just wrap an existing installer).
You should open up ITerm2 (installed above) and make it the default shell and install the terminal utilities (both in the main menu). Pin to dock. Set SauceCodePro Nerd Font as the main font (you can/should do this in the normal terminal, too).
If you want to download the brew bundle (or anything, really) from GitHub, it's a good idea to setup an SSH Key. In short:
ssh-keygen # enter a passphrase pbcopy < ~/.ssh/id_rsa.pub eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa
And add the following to
Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_rsa
While you are at it, feel free to set
git config --global user.name and
git config --global user.email.
If you want to use fish, add
/etc/shells and then run:
chsh -s /usr/local/bin/fish
curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish
This works best when you use the extended fonts in your terminal (Select SauceCodePro Nerd Font), and then run:
set -g theme_nerd_fonts yes fisher add oh-my-fish/theme-bobthefish
Now that zsh comes default, there is less of a need to switch. You may prefer Oh MyZsh instead.
Jupyterlab and key Python utilities
Since you can run kernels from Conda in any JupyterLab install, I like to install it directly into the Homebrew Python 3 instance - but this is now handled through a brew formula for jupyterlab. So far, I still sometimes install the following utilities. You probably should not do this, and just allow homebrew to manage your Python instance, using virtual environment for everything else. But if you do, then run this:
python3 -m pip install pyforest plumbum black
Now, make sure you install
nb_conda_kernels into your conda environments, and you'll be able to see them without activating the environments!
Quality of life
I like to change capslock into escape, which is in keyboard settings, and must be done per-keyboard.
It is important to have installed macvim from brew directly, and not the cask, or otherwise the vi command will not be changed to the new vim. Here is my vimrc, which includes directions. I used to use the ultimate VIM package, but this is much more flexible; still adjusting to fill in gaps. Things will break if you use the system vim; you should at least run:
git config --global core.editor $(which vim)
to make sure you do not open the old vim instead when committing with git. Remove the
$ if you took my suggestion and are using fish.
Remember to run the ycmd setup script after starting up vim!
" On startup, Vim Plug: https://github.com/junegunn/vim-plug will be " installed. Also, all initial plugs will also be installed. " After changing the Plugs or adding this fill run :PlugInstall " And, for youcompleteme, you then need to go to the directory and " run: " python3 install.py --clangd-completer --ts-completer " to build it (or --all, or whatever you use the most). " Use git config --global core.editor $(which vim) to ensure you do " not run system VIM! " " Based on searches from https://vimawesome.com " Automatic install if not yet installed if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif " Vim-Plug call plug#begin('~/.vim/plugged') " Nicer defaults Plug 'tpope/vim-sensible' " Nicer searching Plug 'haya14busa/is.vim' " Nicer status bar Plug 'vim-airline/vim-airline' " Code completer for VIM " Requires brew install vim or macvim Plug 'valloric/youcompleteme' " Github marks in the gutter Plug 'airblade/vim-gitgutter' " File browser Plug 'scrooloose/nerdtree' Plug 'Xuyuanp/nerdtree-git-plugin' " Support EditorConfig Plug 'editorconfig/editorconfig-vim' " Support Black code formatting Plug 'psf/black' " Remember position when entering a file Plug 'farmergreg/vim-lastplace' call plug#end() " Nicer powerline let g:airline_powerline_fonts = 1 " Nerdtree customize map <C-n> :NERDTreeToggle<CR> " Extra customization set mouse=a set spell " Needed to use is.vim :set hlsearch " MacVim needs a nicer font too set guifont=SauceCodePro\ Nerd\ Font " Reasonable indentations set expandtab tabstop=4 shiftwidth=4 softtabstop=4 autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4 autocmd Filetype ruby setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2 autocmd Filetype html setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2 autocmd Filetype markdown setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2 autocmd Filetype css setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2 autocmd Filetype scss setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2