Skip to content

Instantly share code, notes, and snippets.

@benlind
Last active December 4, 2025 22:54
Show Gist options
  • Select an option

  • Save benlind/7dc0e196a7ae59fa1d867bce153258fc to your computer and use it in GitHub Desktop.

Select an option

Save benlind/7dc0e196a7ae59fa1d867bce153258fc to your computer and use it in GitHub Desktop.
New Mac Environment Setup

New Mac Environment Setup

These items are ordered by priority to reduce annoyance when first setting up a new mac.

TODO

Set up Emacs-like keyboard shortcuts everywhere

mkdir ~/Library/KeyBindings ; vim ~/Library/KeyBindings/DefaultKeyBinding.dict

Enter the following code:

{
  // Mac has built-in C-k support, but it doesn't put the killed text onto the
  // system clipboard (you have to C-y to access the killed value). The
  // following line puts it on the clipboard instead.
  "^k" = (setMark:, moveToRightEndOfLineAndModifySelection:, cut:);
  "^ " = setMark:;
  "^/" = undo:;
  "^w" = deleteToMark:;
  "^v" = pageDown:;
  "~b" = moveWordBackward:;
  "~c" = (capitalizeWord:, moveForward:, moveForward:);
  "~d" = deleteWordForward:;
  "~f" = moveWordForward:;
  "~l" = (lowercaseWord:, moveForward:, moveForward:);
  "~u" = (uppercaseWord:, moveForward:, moveForward:);
  "~v" = pageUp:;
  "~w" = (deleteToMark:, setMark:, yank:, swapWithMark:);
  "~B" = moveWordBackwardAndModifySelection:;
  "~F" = moveWordForwardAndModifySelection:;
}

(The "~ " one gets Mac to not insert non-breaking spaces on Opt + Space.)

You can verify that this worked by restarting Chrome and then doing Opt + F/B in the URL bar. It should do word forward/backward instead of printing glyphs.

Disable the press-and-hold for accents feature to enable key repeating:

defaults write -g ApplePressAndHoldEnabled -bool false

Install Chrome

Log into iCloud

Do this in System Preferences.

Install 1Password

Also install the 1Password Chrome extension. This might automatically be done for you when you sign into Chrome. You will need to get the classic extension which doesn't require a 1Password account.

Set up Mac OS Preferences

  • Accessibility
    • Display > Pointer > Shake mouse pointer to locate: off
  • Appearance
    • Appearance: Dark
    • Click in the scroll bar to: Jump to the spot that's clicked
  • Menu Bar
    • Sound > Always Show
  • Desktop & Dock
    • Automatically hide and show dock: on
    • Close windows when quitting an app: off
    • Hot Corners:
      • Top left: none
      • Top right: none (RIP Dashboard)
      • Bottom right: Start Screen Saver
      • Bottom left: Desktop
  • Siri: disabled
  • Touch ID & Password
    • Touch ID: Add both index fingers and the right index finger twice (for better coverage)
    • Unlock with Apple Watch: on
  • Sound
    • Play sound on startup: off
  • Keyboard
    • Keyboard
      • Key Repeat: fastest
      • Delay Until Repeat: one short of fastest
    • Text input > Input Sources > Edit...
      • Add period with double-space: off
  • Trackpad
    • Point & Click
      • Tracking speed: slightly below middle
      • Tap to click: on
      • Quiet Click: on
      • Force Click: off
    • More Gestures
      • Swipe between pages: off
  • Mouse
    • Scroll direction: Natural
    • Secondary click: on
    • Tracking speed: one above middle
  • Displays
    • Night Shift: Sunset to Sunrise
  • Lock Screen
    • Battery: Turn display off after 10 minutes

This is necessary because if you uncheck Mouse > Natural Scrolling that will also reverse the trackpad.

I tried UnnaturalScrollWheels because Scroll Reverser says it will one day be paid, but UnnaturalScrollWheels doesn't reverse magic mice.

Show hidden Finder files

Cmd + Shift + .

Copy the config from another computer (~/.config/karabiner/karabiner.json). This will contain shortcuts for opening apps.

If setting up from scratch, go to Complex modifications > Add predefined rule > Import more rules from the internet. Search for "Tap Caps Lock for ESC or Hold for Control" and click Import, then enable it.

Also set up per-app shortcuts:

Shortcut App
⌘1 Google Chrome
⌘2 Mail or Gmail nativefier app
⌘3 Spotify
⌘4 WhatsApp
⌘5 Anki
⌘6 Calendar
⌘8 iTerm
⌘⌃0 Finder
⌘⌃9 Reminders
⌘⌃' VS Code
⌘⌃; Webex
⌘⇧1 Obsidian
⌘⇧2 ChatGPT
⌘⌥ + Tab Messages
⌘⌥` Slack
⌘⌥\ 1Password
⌘⌥⇧d iCloud Drive > Automator > Toggle Dark Mode

In the Parameters tab change to_if_alone_timeout_milliseconds to 500. I believe this will reduce the time I have to wait if I press Escape down by itself but decide I want to release it without triggering an escape.

If using an external keyboard, set up its custom keymappings.

Configure iTerm

This comes bundled with Mac now.

I have uploaded some starter settings for iTerm here. Go to iTerm > Preferences > General > Settings and check "Load preferences from a custom folder or URL" to use this file.

Make iTerm the system default terminal via iTerm2 > Make iTerm2 Default Term.

Note, you will need to install Oh My Zsh first.

You can also install Powerline/powerlevel10k first to get fancy prompts. If you do this, you may want to disable the git branch name truncation.

Install Pastebot

I purchased this from the Mac App Store, so it might be accessible on other devices for free in the future.

Use the hotkey Ctrl + Opt + V.

Execute Settings Sync: Turn On... and sign in with GitHub.

To get code to work on the command line, open VS Code and run the command "Install code command in PATH".

Configure git

  1. Generate a new SSH key: cd ~/.ssh && ssh-keygen
  2. ssh-add ~/.ssh/id_rsa
  3. Copy the id_rsa.pub contents to my GitHub profile
  4. git config --global user.name "Ben Lind"
  5. git config --global user.name "$email"
  6. git config --global pull.rebase true (rebase when pulling by default instead of creating merge commits)
  7. git config --global push.autoSetupRemote true (no need for git push -u origin $branch anymore)

Install Homebrew

Download and install the .pkg Mac installer.

Give Homebrew precedence in your PATH via .zshrc:

export PATH="/opt/homebrew/bin:$PATH"

If you get this warning on zsh startup:

compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew

Run brew doctor to clean it up.

If you get Insecure completion-dependent directories detected from oh-my-zsh, see the shell setup README.

Install homebrew git, zsh, and bash

These already comes with Mac, but they are slightly older versions and it's nice to be able to update manually.

brew install git zsh bash

Install delta for better git diffs

https://dandavison.github.io/delta/get-started.html

Install Stay

Stay is a window manager that helps with multi-display setups. It will rearrange your open windows according to a config file whenever you connect or disconnect an external monitor.

Install Rectangle

Set up the "almost maximize" configuration:

defaults write com.knollsoft.Rectangle almostMaximizeHeight -float 1
defaults write com.knollsoft.Rectangle almostMaximizeWidth -float 0.8

Should be able to export/import the rest of the configs from another computer.

Keyboard shortcuts:

  • Left Half: ⌥⌘←
  • Right Half: ⌥⌘→
  • Center Half: ⌥⌘↓
  • Maximize: ⌥⇧⌘F
  • Almost Maximize: ⌥⌘↑
  • Maximize Height: ⌃⌥⇧↑
  • Center: ⌥⇧⌘C
  • Next Display: ⌥⇧⌘→
  • Previous Display: ⌥⇧⌘←

I used to use Spectacle but it was abandoned sometime before Sep 2021.

Install ack

brew install ack

Install Alfred

Disable the Spotlight Cmd + Space shortcut by going to the Spotlight pref pane, clicking Keyboard Shortcuts, and unchecking any associated shortcuts.

Set up app-specific shortcuts

In System Preferences > Keyboard > Shortcuts > App Shortcuts, add the following items:

App Menu Item Shortcut Notes
Mail Insert Bulleted List ⇧⌘8
Add... ⌘K
Save Attachments... ⇧⌘S
Send ⌘⏎
Mailbox Search ⌘F
Find... ⌥⌘F
Mail Help ⇧˄⌘/ So that Cmd + Shift + / opens the menu search instead of launching Help
Spotify Private Session ⌘P
Preview Adjust Size... ⌥⌘I
Google Chrome Bookmark This Tab... ⇧⌘D
Calendar Show Calendar List ⌘B
Hide Calendar List ⌘B
By Day ⌥⌘1
By Week ⌥⌘2
By Month ⌥⌘3
By Year ⌥⌘4
Webex Start or stop video on a call ⇧⌘V
Mute or Unmute Yourself ⇧⌘A
ChatGPT Toggle Sidebar ⌘B
iTerm Screen ⇧˄⌥⌘P So that an accidental ⌘P doesn't trigger Print

Set up desktop wallpapers

These are stored in iCloud Drive > Desktop Wallpapers. Download them and have each display randomly cycle through them.

Configure screenshots

Save to ~/Downloads:

defaults write com.apple.screencapture location ~/Downloads

Don't show the floating thumbnail (which delays the screenshot actually showing up in ~/Downloads by a few seconds) by hitting Cmd + Shift + 5, clicking Options, and un-checking the floating thumbnail option.

Install other apps:

  • Backblaze
  • Dropbox (for org files)
  • Obsidian
    • Add a custom icon (iCloud Drive > obsidian icons)
  • Glance
  • Aliento (for closing notifications with a keyboard shortcut—use ⌘⌥⇧K)

Install Chrome extensions

These should be auto-installed via the browser's sync process.

  • uBlock Origin Lite
  • tabToWindow for moving tabs between windows. Change the "next window" keybinding to Cmd + Shift + S, and remove every other keyboard shortcut.
  • Tampermonkey (Chrome & Firefox). Set up settings sync to sync your scripts to Google Drive (I set this up for work but not yet for personal).
  • Stylus (Chrome & Firefox). Set up settings sync to sync your scripts to Google Drive (I set this up for work but not yet for personal).

Vimium (Chrome) or Vimium-FF (Firefox)

Use these custom key mappings:

# Insert your preferred key mappings here.

# On Mac, "alt-p" actually maps to the pi character
map <a-π> togglePinTab

unmap W
unmap p
unmap P
map <c-f> LinkHints.activateModeToOpenInNewForegroundTab

# Unmap commands that I often accidentally hit
unmap p
unmap `

Set up sudo to use Touch ID

https://apple.stackexchange.com/questions/259093/can-touch-id-on-mac-authenticate-sudo-in-terminal

Install nvm

Install node

nvm install --lts

That should set the LTS version up as the default for you.

Update npm

nvm install-latest-npm

Install yarn

npm install --global yarn

Hide Desktop icons

defaults write com.apple.finder CreateDesktop false && killall Finder

If that fails with Could not write domain com.apple.finder; exiting, then:

su blind-admin
sudo chown -R blind:staff /Users/blind/Library/Preferences/com.apple.finder.plist

Set up SMS text message forwarding from iPhone

Unless you do this, you will only be able to see/send iMessages from the Mac Messages app.

On your iPhone, go go Settings > Messages > Text Message Forwarding. Toggle the new computer on.

Hush the terminal's "last login" message

touch ~/.hushlogin

Remove the incessant MacOS 15 "app is accessing your screen" warnings

Install https://github.com/luckman212/screencapture-nag-remover

Backing up a Computer

Here are some things you should make sure to back up before wiping a hard drive:

  • TamperMonkey scripts
  • Stylus styles
  • Home directory dotfiles (e.g., ~/.shell/work)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment