Skip to content

pghk/dotfiles

Repository files navigation

.files

These are the scripts and configuration files that I use to set up a computer the way I like to do

Codemagic build status

Overview

The underlying framework here is provided by chezmoi, which allows me to manage multiple versions of the setup, by using templates.

Some highlights:

  • custom window management functions, written for Hammerspoon
  • command line auto-completion which first suggests previously successful commands (prioritizing those run in the current directory), before falling back to standard options ( zsh-autosuggestions, ZSH History Database, zsh-completions)
  • a script that moves to the trash anything in the ~/Downloads folder older than 30 days. Once a crontab one-liner, now a .plist for launchd that I wrapped in an Applescript "app" just so it could have a custom icon in the preferences pane, which now seems to have the generic script icon anyway
  • a Brewfile composed of separate profiles for first-boot (no service dependencies), long-term (connected to password management and cloud storage), personal and work, used to install apps with homebrew-bundle and mas-cli

Usage

  1. Step through the initial macOS setup dialog, skipping everything that's optional
  2. Open the Terminal app and run xcode-select --install
  3. Open Safari to https://brew.sh and download the .pkg asset for the latest release (i.e. 4.1.20)
  4. System settings > Privacy & Security > Full Disk Access > Add Utilities/Terminal (in order to be able to set macOS settings later via the defaults command)
  5. curl https://raw.githubusercontent.com/pghk/dotfiles/develop/scripts/install.sh > setup.sh and run it
  6. Answer prompts from install script, choosing the profile init
  7. Wait for software to be installed and macOS settings to be applied, then reboot
  8. Start Kitty, Karabiner, Hammerspoon
  9. dot init - answer prompts again, choosing the profile (personal|work)
  10. Sign in to iCloud etc
  11. dot apply to install more software
  12. Start Alfred, Bartender, iStat menus
  13. Erase everything and start over
  14. Repeat 7 to 26 more times, performing experiments, taking notes and making small tweaks along the way until the process actually goes smoothly
  15. Plug in your backup drive and copy over everything you can't remember if it's important or not
  16. defaults write com.apple.menuextra.clock IsAnalog -bool true

Helper scripts

Common setup tasks can be performed by running these manually:

  • dump_macos_settings.sh - writes the output of defaults read to a file named from the current time. Run this before and after changing settings in the UI, then review the diff to discover how you might be able to codify the change
  • set_machine_name.sh - sets HostName, LocalHostName, and ComputerName by calling scutil
  • setup_dock.sh - arranges the items in the macOS dock by removing everything and then putting back the listed items
  • test.bats - asserts in CI that this tool works properly

Additional resources

  • chezmoi - Manage your dotfiles across multiple diverse machines, securely.
  • Awesome Dotfiles
  • Homebrew / homebrew-cask - The Missing Package Manager for macOS
  • mas-cli - Mac App Store command line interface
  • Mackup - Keep your application settings in sync. I'm not actually using this right now, but it's a good resource for finding out where apps store their preferences
  • Prezto - The configuration framework for Zsh
  • ZSH History Database - A slightly better history for Zsh
  • Hammerspoon - Staggeringly powerful macOS desktop automation with Lua