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.
- Basics
- Shell and iTerm2
- Git
- R installation
- Code editor
- Latex
- Other software
- Zotero
- Extras
- LLM/AI Stuff
- References
Still TO-DO: R stuff (gcc, spatial)
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
- Disable automatic spelling correction, word capitalisation, and full stop with double-space, in
Keyboard>Spelling - Enable ‘Keyboard navigation’ to move panels with
Tab, inAccessibility>Keyboard
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:
- It’s useful to give iTerm2 access to Full disk under Privacy settings, so as to avoid the
operation not permittedwhen usingfind - In Settings > Profiles > Keys, change a couple things so you can move through words with alt and arrows:
- In ⌥->, change it to “Send Escape Sequence” and write “f” in Esc+
- In ⌥<-, change it to “Send Escape Sequence” and write “b” in Esc+
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
R installation
Still TO-DO:
- Makevars and gcc
- Important: Do NOT install R through homebrew
- Use standard R installation, through r-project.org
- Change appearance colors
- Get configuration from
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
Extra libraries to use in R
- TODO: spatial analyses, etc
Code editor
I use Sublime Text with the following packages installed:
AutoFileNameBracketHighlighterFileBrowseriOpenerLaTeXSmartQuotesLaTeXToolsMarkdown ExtendedMarkdownPreviewPackage ControlR-IDESendCodeSideBarEnhancementsSublimeLinter-contrib-write-goodSync SettingsWhitespaceWordingStatusCiteBibtex- and maybe others, which are keep in the configuration files
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): 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.
Probably better to go directly to: MacTeX site
Also, install bibtex-tidy (see this) (needs npm):
npm install -g bibtex-tidy
Other software
brew install pandoc
brew install pandoc-crossref
brew install rar
brew install --cask skim
brew install --cask brave-browser
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 dropbox
brew install --cask google-drive
brew install --cask proton-drive
brew install --cask docker
brew install node
brew install --cask notunes
brew install --cask betterdisplay
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 graphviz
brew install --cask aldente
brew install --cask coconutbattery
brew install --cask vlc
brew install gnumeric
pip install xlsx2csv
brew install httpie
brew install jq
- Probably want to switch from Spectacle to Rectangle:
brew install --cask rectangle
Set ups to consider:
- Bluesnooze: open at login?
-
Set up
fzf- Add this to
.zshrc:
- Add this to
# 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:
- Also useful to install Présentation.app,
.pkgavailable from their website: iihm.imag.fr/blanch/software/osx-presentation/- Check also this to use it from the command line
Quick configurations
Spectacle:
- Allow access to app in Accesibility
- My key strokes:
- Full screen: ⌥ alt ⌘ cmd + F
- Left half and right half: ⌃ ctrl ⌥ alt ⌘ cmd + <- / ->
- Next display: ⌥ alt ⌘ cmd + P
- Upper/lower right: ⌃ ctrl ⌥ alt ⌘ cmd + up arrow / down arrow
Quicksilver:
- Allow access to app, iTerm2 plugin, set Catalog
- Keystrokes
- Quicksilver: ⌘ cmd + Space
- Search in Finder: ⌥ alt ⌘ cmd + Space
- Spotlight: ⌃ ctrl ⌥ alt ⌘ cmd + Space
Others:
- Log in to Google Drive and Dropbox
- Install digital certificate
- Set noTunes to launch at startup (General > Login Items)
Zotero
- Check this post
- Using mainly two plugins: Better BibTex and Attanger
- Optionally a third one for tag management: Zutilo
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_libraryin iCloud) and metadata directory (do not sync this)
Better BibTex
- Citation key formula:
auth(0,1) + auth(0,2) + auth(0,3) + ":" + year - Field to omit from export:
shorttitle,issn,urldate,abstract,langid,file,copyright,date-modified,date-added,doi,month - Quick-copy latex citation (command:
citep) - Automatic export on change
- Set Library (
~/Dropbox/REF.bib)
Attanger
- Choose root directory (
~/Downloads) - Destination path, subfolder:
{{ authors max="1" case="lower" }}
- Filename (‘Customize Filename Format…’):
{{ authors max="1" suffix="_" case="snake" }}{{ year suffix="_" }}{{ title truncate="100" case="snake" }}
Two more notes:
- Maybe some of these setups changes when migrating to Zotero 9 or later
- Enable the API (in
Prefs > Advanced > Allow other applications...)
##
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
Maybe it is useful to install a version manager, such as pyenv:
brew update
brew install pyenv
And then:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init - zsh)"' >> ~/.zshrc
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. 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
duti -s org.videolan.vlc .mp3 all
Keyboard shortcuts
LLM/AI
Ollama
brew install ollama
Remember to run the Ollama server so it runs, by ollama serve.
Install a light LLM and an embedding model:
ollama pull phi4-mini
ollama pull snowflake-arctic-embed2
Open WebUI
curl -LsSf https://astral.sh/uv/install.sh | sh
And open by DATA_DIR=~/.open-webui uvx --python 3.11 open-webui@latest serve or adding an alias (already in configfiles/.aliases).
Check these references:
- [Open WebUI Docs - ]
- Build your local AI
- Supercharge Your Local AI with RAG and Custom Knowledge Bases
- Beyond Text
- YouTube: How to connect a LLM to Zotero for a private, local research assistant
Claude Code
Add settings.json to ~/.claude/, and write:
{
"permissions": {
"deny": [
"Bash(git commit*)",
"Bash(git push*)"
]
},
Install a couple plugins from pchalasani/claude-code-tools:
claude plugin marketplace add pchalasani/claude-code-tools
claude plugin install "safety-hooks@cctools-plugins"
claude plugin install "workflow@cctools-plugins"
These are the safety hooks and some workflow tools.
Note (need to update this):
- MCP: filesystem (especially for Obsidian vault) and Zotero
References
- See this guide