Ramón y Cajal Associate Professor
Department of Social Sciences
Universidad Carlos III de Madrid
francisco.villamil@uc3m.es
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.
Still TO-DO: R stuff (gcc, spatial)
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)"
Keyboard
> Spelling
Tab
, in Accessibility
> Keyboard
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:
operation not permitted
when using find
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
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
Still TO-DO:
configfiles
: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
I use Sublime Text with the following packages installed:
AutoFileName
BracketHighlighter
FileBrowser
iOpener
LaTeXSmartQuotes
LaTeXTools
Markdown Extended
MarkdownPreview
Package Control
R-IDE
SendCode
SideBarEnhancements
SublimeLinter-contrib-write-good
Sync Settings
Whitespace
WordingStatus
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
I also have the following aliases defined in .zshrc
, to manage the settings folder (access, update, and upload) and open both files and current directories with Sublime Text:
alias stfolder="cd ~/Library/Application\ Support/Sublime\ Text/Packages/User"
alias updatest="cd ~/Library/Application\ Support/Sublime\ Text/Packages/User && gitfs && git pull"
alias uploadst="cd ~/Library/Application\ Support/Sublime\ Text/Packages/User && gitfs && gitacp"
alias subl='open -a "Sublime Text" "$@"'
alias openfs='open ${PWD} -a "Sublime Text"'
Alternatively, to make the subl
command work:
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
},
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
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
brew install --cask alt-tab
brew install --cask karabiner-elements
brew install bluesnooze
brew install fzf
brew install autojump
brew install fd
brew install tree
brew install ripgrep
brew install rga
brew install poppler ffmpeg
brew install lsd
brew install bat
brew install --cask rectangle
Set ups to consider:
Set up fzf
.zshrc
: # Set up fzf key bindings and fuzzy completion
source <(fzf --zsh)
_fzf_compgen_path() {
command fd --hidden --follow --exclude .git --exclude node_modules . "$1"
}
_fzf_compgen_dir() {
command fd --type d --hidden --follow --exclude .git --exclude node_modules . "$1"
}
* And run: `export FZF_DEFAULT_COMMAND='fd --type f'`
Other apps:
.pkg
available from their website: iihm.imag.fr/blanch/software/osx-presentation/
Spectacle:
Quicksilver:
Others:
General preferences
General
: Disable snapshots when importing from websites, Item header (citation, Nature)Sync
: Setup sync accountExport
: Optional: style when exportingAdvanced
: Setup file directory (zotero_library
in iCloud) and metadata directory (do not sync this)Better BibTex
auth(0,1) + auth(0,2) + auth(0,3) + ":" + year
shorttitle,issn,urldate,abstract,langid,file,copyright,date-modified,date-added,doi,month
citep
)~/Dropbox/REF.bib
)Attanger
~/Downloads
)
{{ authors max="1" case="lower" }}
{{ authors max="1" suffix="_" case="snake" }}{{ year suffix="_" }}{{ title truncate="100" case="snake" }}
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
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. First, csv
files with Modern CSV:
duti -s net.galliumdigital.Modern-CSV .csv all
Skim for pdf
:
duti -s net.sourceforge.skim-app.skim .pdf all
All plain text (txt, R, Markdown, shell, Latex) with Sublime Text:
duti -s com.sublimetext.4 .txt all
duti -s com.sublimetext.4 .md all
duti -s com.sublimetext.4 .R all
duti -s com.sublimetext.4 .tex all
duti -s com.sublimetext.4 .sh all
duti -s com.sublimetext.4 .zsh all