Francisco Villamil

Assistant Professor
Department of Social Sciences
Universidad Carlos III de Madrid
francisco.villamil@uc3m.es

               

About
Publications
Teaching
Data & Code
Media

Setting up a new macOS environment

This is my own guide to set up a new mac computer. It covers the basics for code development (shell, git, R, Latex, code editor, etc) and some other useful applications for academic research.

TODO:


Basics

Install XCode:

xcode-select -—install

Install Homebrew, and follow instructions in installation:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Annoying system settings


Shell and iTerm2

Install iTerm2, and oh-my-zsh:

brew install --cask iterm2
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

In older versions installing zsh might be necessary. Also, if you get an error like /Users/../.zshrc:source:75: no such file or directory: /Users/../.oh-my-zsh/oh-my-zsh.sh, uninstall and install oh-my-zsh again.

Install Powerlevel10k theme, close iTerm2, open again and go through configuration wizard:

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc

NOTE:


Git

Install git via homebrew and check that version has changed been updated:

git --version
brew install git
git --version

If version doesn’t change, try:

export PATH=/usr/local/bin:$PATH
git --version

Add cached credentials to log in locally (see this guide):

brew install --cask git-credential-manager

Just clone any private repository to set it up. Maybe useful to do this afterwards:

git config --global user.name "Fran Villamil"
git config --global user.email francisco.villamil@uc3m.es

Extras

Also install Github CLI (gh)

brew install gh

Get configurations from configfiles:

Clone configfiles repository and create symlinks for terminal and git:

cd
git clone https://github.com/franvillamil/configfiles
rm ~/.zshrc && ln -s ~/configfiles/.zshrc ~/.zshrc
rm ~/.p10k.zsh && ln -s ~/configfiles/.p10k.zsh ~/.p10k.zsh
ln -s ~/configfiles/.aliases ~/.oh-my-zsh/custom/aliases.zsh
rm ~/.gitconfig && ln -s configfiles/.gitconfig  ~/.gitconfig

Note: aliases go in a separate file (.aliases, pointed by a symlink in .oh-my-zsh/custom/), see this thread.

Get p4merge (optional):

brew install --cask p4v

The configuration for git should already be in configfiles, but just in case, it is:

[diff]
    tool = p4mergetool
    renames = copies
    mnemonicprefix = true
[difftool "p4mergetool"]
    cmd = /Applications/p4merge.app/Contents/MacOS/p4merge "$LOCAL" "$REMOTE"
    keepBackup = false
    keepTemporaries = false
    trustExitCode = false
    prompt = false

Other useful software

brew install pandoc
brew install pandoc-crossref
brew install --cask skim
brew install --cask brave-browser
brew install --cask dropbox
brew install --cask quicksilver
brew install --cask spectacle
brew install --cask modern-csv
brew install --cask spotify
brew install --cask autofirma
brew install --cask adobe-acrobat-reader
brew install --cask firefox
brew install --cask gimp
brew install --cask protonvpn
brew install --cask selfcontrol
brew install --cask skype
brew install --cask zoom
brew install --cask zotero
brew install --cask calibre
brew install --cask obsidian
brew install --cask google-drive
brew install node
brew install --cask notunes
brew install gpsbabel
brew install pdftk-java

Quick configurations

Spectacle:

Quicksilver:

Others:


R installation

ln -s ~/configfiles/.Rprofile ~/.Rprofile
ln -s ~/configfiles/.Renviron ~/.Renviron

gcc stuff for compilations in R (in case it’s needed)

NOTE: check this post before. Looks like macOS Ventura comes with gcc and g++ 14, maybe it is enough to point to their location (by default in /usr/bin/) in a new Makevars file? Instead to download it through Homebrew (see also this post). But if I do want to do that, follow:

brew install gcc

And then add this to Makevars, but first check version of gcc and directories etc (perhaps need to create it: cd && mkdir .R && touch .R/Makevars):

CC = gcc-12
CXX = g++-12
FLIBS = -L/opt/homebrew/lib/gcc/12/gcc/aarch64-apple-darwin20/12 -L/opt/homebrew/lib/gcc/12 -lgfortran -lquadmath -lm

Extra libraries to use in R

Code editor (Sublime Text)

I have the following packages installed:

Configuration is saved in a (private) git repository, which also enables syncing. In a new computer, just install Package Control and then clone the repository into the following folder, in a new folder called User:

cd Library/Application\ Support/Sublime\ Text/Packages

Also, so the subl command works:

sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

Note: SendCode settings are not stored in /Packages/User/ but directly in Packages (why?), so they do not sync. It’s possible that for code to be sent to the right app, you need to change SendCode (OSX).sublime-settings, e.g.:

    "r" : {
        "prog": "r",
        // turn bracketed_paste_mode on if radian or readline 7.0 is in use
        "bracketed_paste_mode": false
    },

Latex

brew install –cask mactex eval “$(/usr/libexec/path_helper)”

NOTE: I’m not sure it’s the best idea to install it through homebrew, see this post.

Also, install bibtex-tidy (see this) (needs npm):

npm install -g bibtex-tidy

Extra configurations

Add python to PATH

Python3 should be installed by now in homebrew. Maybe check:

where python3

To check the versions installed, try ls /opt/homebrew/opt/. Also useful to check brew info python. (See this).

Now add it to the PATH (careful with version):

echo 'export PATH=/opt/homebrew/opt/python@3.11/libexec/bin:$PATH' >> ~/.zprofile
source ~/.zprofile

File type defaults

Install duti:

brew install duti

If you need to check the code for an application, assign it manually and then check the defaults with duti:

duti -x sh

And then change some defaults:


Further references