~
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”
-
I automate as little of the initial setup as possible (installing apps etc.). Spending time automating something that it’s quite unlikely I’ll ever run again on the same OS, the same hardware, or even the same desired end goal, just wasn’t worth the effort for me.
-
I only change the defaults when I absolutely have to.
Highlights
-
I use a bare git repository - mads-hartmann/dotfilesv2 - in my
$HOME
folder for the actual dotfiles -
I maintain a little setup guide for the few occasions where I actually have to set up a new mac from scratch (see below).
-
I use ZSH as my shell (that’s the default since macOS Catalina). I use Spaceship as my prompt configuration.
Setting up a new mac
- Install 1Password
- Install command-line tools
- Install Homebrew & essential apps
- ZSH configuration
- SSH configuration
- Setting up dotfiles
- Visual Studio Code
- 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
- Alfred. I use this as an app launcher, dictionary, clipboard manager.
- TaskPaper
- BetterSnapTool
- TablePlus
-
Please let this be the final version. ↩