~

I’ve tried a lot of different approaches to managing my dotfiles over the years. They varied in scope and complexity, but they all eded up being too much work to maintain. So this is my final iteration1.

“philosophy”

Highlights

Setting up a new mac

  1. Install 1Password
  2. Install command-line tools
  3. Install Homebrew & essential apps
  4. ZSH configuration
  5. SSH configuration
  6. Setting up dotfiles
  7. Visual Studio Code
  8. Other essential apps

Install 1Password

I use 1Password for all my personal credentials. Install it using the App Store (direct link)

Install command-line tools

Install all the command-line tools like make, git, etc.

xcode-select --install

Install Homebrew & essential apps

Install homebrew so we can install all the other things we’ll need:

/usr/bin/ruby \
    -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

iTerm is my terminal of choice:

brew install --cask iterm2

I use the Fira Mono for Powerline at the moment:

brew install svn # Needed for font-fira-mono-for-powerline
brew install font-fira-mono-for-powerline

I use Docker

brew install --cask docker

I almost always end up needed some of the gnu utilities when writing scripts that should work on Linux (e.g. for CI)

brew install coreutils

ZSH configuration

Install ZSH completions:

brew install zsh-completions
sudo chown -R $(whoami) /usr/local/share/zsh/site-functions /usr/local/share /usr/local/share/zsh
sudo chmod -R 755 /usr/local/share/zsh/site-functions /usr/local/share /usr/local/share/zsh

Install starship

brew install starship 

SSH configuration

Mostly taken from Githubs documentation.

Tell sshd to use the macOS keychain:

echo "Host *
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_rsa" > ~/.ssh/config

Generate a new SSH key and add it to your keychain:

ssh-keygen -t rsa -b 4096 -C "mads379@gmail.com"
eval "$(ssh-agent -s)"
ssh-add -K ~/.ssh/id_rsa

Tell Github about your new key:

cat ~/.ssh/id_rsa.pub | pbcopy
open "https://github.com/settings/keys"

Setting up dotfiles

Based on this article.

I use a bare git repostiory in my $HOME folder to track my dotfiler, together with a convenience alias for git named config.

# Set up the bare repository
git clone --bare git@github.com:mads-hartmann/dotfilesv2.git
alias config='/usr/bin/git --git-dir=$HOME/dotfilesv2.git/ --work-tree=$HOME'

# Move things to backup directory for review later.
mkdir -p .config-backup && \
config checkout 2>&1 | grep '\t' | awk '{gsub(/\t/,"", $0);print}' | xargs -I{} sh -c 'mkdir -p ".config-backup/$(dirname "{}")" && mv "{}" ".config-backup/{}"'

# Now checkout the dotfiles
config checkout

Visual Studio Code

Sorry Emacs, I’ve converted:

brew install --cask visual-studio-code

I have a few extensions that I definitely need:

code --install-extension \
  EditorConfig.EditorConfig \
  letrieu.expand-region \
  eamodio.gitlens

The rest of the configuration lives in my dotfiles, so they should already be in place.

Other essential apps

  1. Please let this be the final version.