~

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

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 thigns we’ll need:

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

iTerm is my terminal of choice:

brew cask install iterm2

Install a few things from the app store

  • 1Password. I use it for all my credentials
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 cask install 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

There’s few tools I usually always use:

# common gnu utilities. Almost certainly needed for bash scripts that run on Linux (CI).
brew install coreutils

And some other ones:

  1. Please let this be the final version.