back buttonBlog.

MacOS Setup Scripts

Cover Image for MacOS Setup Scripts
Yesh Malekar
Yesh Malekar

Annoyances:

  • Mouse

    • System Preferences → Set Tracking speed to max.
    • System Preferences → Set Scrolling speed to max.
  • Keyboard

    • Fix slow initial key repeat (great for arrow keys)
    • defaults write -g InitialKeyRepeat -int 10
      
    • Fix slow key repeat (also great for arrow keys)
      • defaults write -g KeyRepeat -int 1:
  • Windows

    • AltTab: Replace the built-in window-switching shortcut Commmand ⌘ Tab ⇥ to add previews, hide windows from other spaces, close windows with Control ⌃ w and Control ⌃ q, etc.
    • Don't automatically switch spaces when clicking on the dock.
      • defaults write com.apple.dock workspaces-auto-swoosh -bool NO
    • System PreferencesMission Control → Untick When switching to an application, switch to a Space with open windows for the application.
    • Magnet ($7.99): Basic Windows-like window snapping to screen edges (+ shortcuts). No animations for snapping. Note that BetterTouchTool also embed this feature.
  • Sound

    • Auto-mute output audio devices (except Bluetooth) when Mac wakes from sleep. Avoids blasting loud sound when you open your Macbook in public transport. Using Hammerspoon:
      • brew install hammerspoon
      • Download SpoonInstall and unzip it in ~/.hammerspoon/Spoons/
      • Create ~/.hammerspoon/Spoons/init.lua with the following content and then reload Hammerspoon's configuration:
      hs.loadSpoon("SpoonInstall")
    
      spoon.SpoonInstall.repos.devnoname120 = {
        url = "https://github.com/devnoname120/hammerspoon-collection",
        branch = "build",
      }
    
      spoon.SpoonInstall:andUse("AutoMuteOnSleep", {repo="devnoname120", start=true})
    
  • Battery

    • System PreferencesBatteryBattery → Tick Low power mode
      • ×2 my battery time, and can't notice any difference in snappiness.
  • Dev

    • Using touch id for sudo authentication:
      • Add auth sufficient pam_tid.so to top of /etc/pam.d/sudo
      • In iTerm2, Open settings —> Advanced —> Allow sessions to survive logging out and back in —> No
      • You will need to do that again at every macOS update
  • Finder

    • Always display the current path at the bottom:
      • Finder menu → PreferencesShow Path bar
      • Or defaults write com.apple.finder ShowPathbar -bool true
    • Show file extensions:
      • FinderPreferences…AdvancedShow all filename extensions
    • Show useful folders in the sidebar:
      • FinderPreferences…SidebarAdd Projects & Personal folders
    • Don't keep open previously previewed files
      • defaults write com.apple.Preview ApplePersistenceIgnoreState YES
  • System Settings

⚠️ You need to log out and then log back in to apply defaults write changes.

  • Performances
    • Fix mds/mds_store/md_worker high CPU usage (Spotlight indexing)
      • System PreferencesSpotlightPrivacy → Add the following paths:
      /usr, /bin, /sbin, /opt, /private, /Library
      /System/{Library, Application Support}
      ~/.cache
      ~/Library/{Caches, Logs, Application Support, Containers, Group Containers}
      
      • You can find more paths to exclude in mds's logs
        • sudo fs_usage -w -f filesys mds
      • You will need to do that again at every macOS update
  • Bugs
    • When Macbook Air M1 is sleeping, external screens connected via USB-C keep waking up every few minutes and then go straight to sleep again.
      • Workaround (source):
        • sudo pmset -a tcpkeepalive 0
        • sudo pmset -a powernap 0
        • Disable System PreferencesBatteryOptimized battery charging
        • Disable System PreferencesBatteryPower AdapterWake for network access
      • See the reasons of the past wakes
        • pmset -g log | grep 'due to'

Shortcuts:

  • General
  • Finder
    • Commmand ⌘ Option ⌥ v: Paste copied item and remove it from original location.
    • Hold Option ⌥: Reveal path breadcrumbs.
      • Right click on a breadcrumb to copy path or open in terminal.
    • Commmand ⌘ ↑: Move to parent directory.
    • Commmand ⌘ ↓: Open directory/file.
      • Commmand ⌘ o: Does the same thing.
    • Commmand ⌘ Shift ⇧ g: Go to path.
    • Commmand ⌘ Option ⌥ c: Copy path of highlight file/directory.
    • Commmand ⌘ Shift ⇧ .: Show hidden files.
      • Make it the default: defaults write com.apple.finder AppleShowAllFiles YES.
  • Other apps:

Multimedia:

  • Shottr: Free screenshot app + annotations + OCR zone of screen to clipboard. ❤️
    • [22-04-22] Use v1.5.2 because v1.5.3 randomly crashes.
  • IINA: Awesome video player with great UI on top of mpv (way better than VLC).
    • brew install iina
    • YouTube support:
      • brew install yt-dlp # better than youtube-dl
      • ln -s /opt/homebrew/bin/yt-dlp /opt/homebrew/bin/youtube-dl
      • PreferenceNetworkCustom youtube-dl path/opt/homebrew/bin/
    • More active and up-to-date fork: IINA Plus
      • brew install iina-plus
      • Already includes yt-dlp
  • HandBrake: ffmpeg GUI that helps convert videos.

Productivity:

  • Alfred: Spotlight replacement (search, browse, clipboard history, snippets, workflows).
    • TODO: add my workflows
  • Spark: Awesome productive email client with first-class multi-inbox, archiving/snoozing/sending later emails, etc. Must-have.
  • Fantastical ($43.99/yr): Great calendar app. Event creation using natural language, first-class timezone + weather support
  • MeetingBar: Display time until next meeting in the status bar, and allow opening the meeting link directly.
  • Karabiner: Remap macOS keys.
    • 🔜 TODO share my config file.
  • Finda: Dmenu equivalent that works on everything (open windows, tabs, browser history, etc.).
  • Tracker Zapper: Watches the clipboard and automatically get rid of trackers from copied URLs (utm_source, fbclid, etc.).

UI/UX tweaks:

  • KeepingYouAwake: Prevent macOS from sleeping (temporarily).
  • Dozer: Declutter macOS menu bar by selectively hiding icons.
  • Muzzle: Disable all notifications when sharing screen.
  • Side Mirror: Show second screen (projector) in a window on the main screen. Useful for presentations
  • macOS-key-cast: Display an overlay with macOS keys you type. Useful for recording the screen with QuickTime.
  • Lunar: Control the brightness of external screens via DDC (over HDMI/DP/DP USB-C/TB2&3/VGA/DVI). ⚠️ If you use an adapter or a USB-C cable, it needs to forward DDC messages correctly (if it supports DP over USB-C it should be fine).

Dev:

  • iTerm2: Way better Terminal than the default one.
  • Shell/zsh programs
    • Powerlevel10k: Awesome ZSH theme/plugin. Easy to customize. Works for many shells zsh (default on macOS), bash, etc.
    • mcfly: Awesome shell reverse-search-history replacement for the default clunky Control ⌃ r (aka reverse-i-search).
    • z: Track most frequently used directories and then jump to them easily.
    • SCM Breeze: Add numbered shortcuts to the output of Git, ls, etc.
    • tealdeer: superfast unofficial client for the tldr pages (official client sucks).
      • brew install tealdeer
    • ripgrep: Replacement for find. Blazing fast file search with sane defaults.
    • Zsh antigen plugin manager
      • Plugins (add in .zshrc):
        • Extra command auto-completions: zsh-users/zsh-completions
        • Fish-like grey autosuggestions: zsh-users/zsh-autosuggestions
        • Syntax highlight for shell commands: zsh-users/zsh-syntax-highlighting
  • Syntax Highlight: Preview source code files with syntax highlighting in Finder's Quick Look (opened when pressing space on a file).
  • TextMate: Fast & lean text editor with syntax highlighting. I use it to do quick file edits like I would in the terminal with Vim.
  • OpenInTerminal: Open the current Finder folder in a terminal.
  • DevUtils ($25/device): hacker toolbox. Convert unix timestamps, base64 decode, URI decode, JSON beautifier, test RegExes, etc.
  • Vnc connect: free VNC client that just works.
  • ncdu: visualize disk usage tree to find big files

Backups:

Privacy:

  • Homebrew
    • brew analytics off
  • https://privacy.sexy/

To be reviewed

  • Amethyst: xmonad-like tiling window manager

Hammerspoon:

  • Script for Windows snapping like Spectacle/Rectangle

⚠️ Requires system integrity protection to be disabled.

Dev:

  • redo: interactively create shell function from shell history.

Multimedia:

  • SoundSource: Fine-grained by-app sound control for Mac + precise audio EQ

Productivity:

  • Typinator: auto-expand user-defined abbreviations.
  • Keyboard Maestro: Automate tasks, create macros.
  • Responsively: Test a website on many device screen sizes at once.
  • Paw: Test REST APIs (Postman alternative).
  • Hook: Create local perma-links to anywhere in any documents. Useful for cross-referencing stuff (+ use those links in Obsidian).
  • Timing: Monitor used apps/websites/etc. Looks very powerful.
  • Presentify: Annotate your screen while sharing it or presenting it to an audience.
  • Timing: App-usage time tracking, miles ahead of Apple's native feature

Utilities:

  • Day One App: Journaling app. Claims to be e2e encrypted and to protect users' privacy.
  • rcmd: Switch to apps directly using a option+letter shortcut. ⚠️ Conflicts with qwerty-fr.
  • PDF viewer/annotator
  • espanso: Auto-expanding inline snippets with templating support.