Dot Files and Mac Setup
Being old-fashioned, I always want simplicity and speed. That’s why I use the terminal and NeoVIM. Here’s my setup on Mac. The key is I want to keep this deadly simple, thus when there’s an OK default, I would use that instead of heavily customization. The biggest change over the years is the “defaults” are getting extremely well (Oh-My-Zsh and Lazyvim etc.), and the inclusion of AI-based tools, like Claude Code and ChatGPT.
How to Set Up a New Mac
- Mac desktop basics:
- Dock to the left, hide
- Allow whole-screen zoom in Accessibility (for eyesight of an old man, I use ctrl+scroll)
- Customize modifier key, CAPS LOCK -> ESC (for vim)
- Adjust trackpad scroll speed
- Install Alfred, point settings sync to ~/settings (I put settings here so I can easily
yadmlater)- Alfred is a much nicer command switcher, including 1) multiple clipboard history, 2) global hotkey, 3) snippets (e.g. easy access to
¯\_(ツ)_/¯) - Unbind Cmd+Space from Spotlight to Alfred.
- Alfred is a much nicer command switcher, including 1) multiple clipboard history, 2) global hotkey, 3) snippets (e.g. easy access to
- Set screenshot to iCloud location.
```
- defaults write com.apple.screencapture location “$HOME/Library/Mobile Documents/com~apple~CloudDocs/screenshots”
- killall SystemUIServer ```
- TODO: more
- Set up the terminal
- Use
zsh. - Install Gostty, which is much clearer/faster than
iTerm2, with less features as it’s pretty new.- By now I use Ghostty full time. iTerm’s support for integration with remote tmux is still unique, but I don’t log on remote server for long duration nowadays, so not a requirement anymore.
- The only missing function is you can’t search the scroll back buffer. I bound
cmd+Ito dump the current screen to a file, then I can search it innvim, e.g. I can dov <cmd+I>to generate a dump file and open it with my nvim. - Scroll back search will be available in 1.3.1, according to 1.2.0 release note.
- Or install iTerm2.
- Set it to load from a custom folder in:
Preferences> General > Settings. We will recover settings later inyadm. It’s OK for now.
- Set it to load from a custom folder in:
- Install Oh My Zsh, with command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"Oh My Zshprovides out of box great defaults forzshusers.- Additional
zshplugins:git clone https://github.com/Aloxaf/fzf-tab ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-tabgit clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionsgit clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting
- Get a new font, I use DejaVuSansM Nerd Font, direct link. If you are using
Ghostty, built-in font is already good enough, so no need to install this.
- Use
- Set up
SSHand access toGithub- Assuming you don’t have the keys:
ls ~/.ssh/id\_\*, usessh-keygen -t ed25519 -C "your-email@example.com"to generate, and set up a passphrase to protect it. - Create ssh config file
~/.ssh/configwith the following content. This instructs ssh-add to use keychain.Host \* UseKeychain yes AddKeysToAgent yes IdentityFile ~/.ssh/id\_ed25519 - Add to key to keychain so you don’t need to keep input that passphrase:
ssh-add --apple-use-keychain ~/.ssh/id\_ed25519 - Copy your public key to Github
pbcopy < ~/.ssh/id_ed25519.pub. Add a new SSH key there. - Test setup with
ssh -T git@github.com
- Assuming you don’t have the keys:
- Install
yadmto recover settings- Install Homebrew, which downloads Xcode Command Line Tools. Command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Recover install brews, e.g.
brew bundle --file=~/settings/brewfile- Or install yadm
brew install yadmdirectly. - the command to dump brewfile is
brew bundle dump --file=~/settings/brewfile --describe
- Or install yadm
- Get your configuration from you github repo, mine:
yadm clone git@github.com:xianxu/dotfiles.git - Use
yadm statusand check out what the differences are. It’s great to always have a sane default. - TODO
- Install Homebrew, which downloads Xcode Command Line Tools. Command:
- Set up the terminal-based development environment.
- Get neovim:
brew install neovim - Get Node.js
brew install node - Get Amazon Q
brew install amazon-q - Get Claude Code
npm install -g @anthropic-ai/claude-code - Get OpenAI Codex
npm install -g @openai/codex - Get Gemini CLI
npm install -g @google/gemini-cli - Or just use
brew bundle --file=~/settings/Brewfileto recover brew state.
- Get neovim:
- Install other Mac Apps
ChatGPT,Chrome,Edge,VimR,WhatsApp,Grammerly,Zettlr- Chrome plugins:
Grammarly,Save Pinned Tabs,Switch between recent tabs (MRU tabs switch),Video DownloadHelper. - Safari plugins:
Grammarly,TabBack. - Some small utilities:
Horo(timer),Quick View Calendarfor dates,Magnetfor window control.
- Other settings
- Some shortcuts from ~ to usual locations
- Keychain access of API keys, often for AI related things
- Set up git user name:
git config --global --edit
yadm
I started to use yadm to keep dotfiles in sync. yadm wraps around git and creates the illusion that some files and directories under $HOME are source controlled. Otherwise, it behaves just like git.
brew install yadmyadm clone ...to clone your dotfiles repo. Or check yadm manual on how to initiate a repo from yadm. I’d suggest having a separate private GitHub repo to track your configuration files.- In the ideal case, that’s all you need to do; you have recovered all the configuration files tracked by
yadm! - To track a new file, it’s simply something like:
yadm add ~/.zshrc. You useyadm statusto check what’s changed. Andyadm commit; yadm pushto commit and push your changes to your repo on GitHub. It basically behaves the same asgitcommand. - Some additional files I track:
- Generate homebrew bundle file with
brew bundle dump --describe --file=~/.brewfile. Recover on new host withbrew bundle --file=~/.brewfile - ~/.crontab file contains periodical thing I run on a host. Recover on new host with
crontab ~/.crontab Alfredpreference files in~/Alfred.alfredpreferences/
Software Shortlist on Mac
- Install iTerm2, which is vastly better than Terminal.app, especially if you need to connect to remote servers. Even just for local use, it’s pretty good.
- Install Ghostty, with is much clearer/faster than
iTerm2, with less features as it’s pretty new. For example, there’s no native integration with tmux on remote servers, meaning you can’t map remote tmux operations to local window operations. But if you mainly use local terminal, it is already a good enough replacement of iTerm2. Example configurations: ``` font-family = DejaVuSansM Nerd Font Mono font-size = 15 theme = Apple System Colors quick-terminal-position = bottom focus-follows-mouse = true
keybind = cmd+left=previous_tab keybind = cmd+right=next_tab keybind = cmd+shift+left=move_tab:-1 keybind = cmd+shift+right=move_tab:+1 keybind = cmd+c=copy_to_clipboard keybind = cmd+v=paste_from_clipboard keybind = cmd+i=write_screen_file:paste keybind = cmd+d=new_split:right keybind = cmd+shift+d=new_split:down keybind = cmd+shift+enter=toggle_split_zoom keybind = cmd+shift+equal=equalize_splits copy-on-select = clipboard
keybind = ctrl+h=goto_split:left keybind = ctrl+j=goto_split:bottom keybind = ctrl+k=goto_split:top keybind = ctrl+l=goto_split:right keybind = shift+enter=text:\n
macos-titlebar-style = tabs link-url = true ```
- Install Alfred. I use the
1/multi clipboard,2/global hot keys, and3/snippets (e.g. having quick access to ASCII art like¯\_(ツ)_/¯, for example). - Use
zsh, a modern shell. - Use Oh My Zsh to customize your
zsh. It adds all the cool bars and fonts here and there, and also much better command completion. It does all those largely out of the box. - Install HomeBrew, which makes installing software on Mac much easier. e.g.
rg,ack,nvim, etc. - You will need some fonts to display some weird Unicode codepoints. I use nerd fonts, in particular,
DejaVuSansMNerdFontPropo-Regular.ttf. - Some small utilities:
Horo(timer),Quick View Calendarfor dates,Magnetfor window control.