Tools and instructions to speed up and automate my setup and configurations after clean re-installation of MacOS.
MacOS, the following setup has a clean installation in mind.
If you want to make your own setup based on this one I recommend the following steps:
- Fork the repository
- Edit the Brewfile
- Some apps however are required for later steps (e.g. nerd-font, iTerm2, mas, nvm, neofetch, jq, rbenv, p10k, zsh-*)
- Edit settings.sh to suit your own preferences
- The github repo https://github.com/mathiasbynens/dotfiles contains a lot of like minded tweaks.
- Edit mixin/aliases
- PS. before you start adding your own aliases I recommend running
alias
and looking at what is already there, a lot of stuff comes with the Oh-My-Zsh plugins.
- PS. before you start adding your own aliases I recommend running
- Follow the manual setup guide
The setup process is manual but I find it helpful to split it up into stages.
This stage sets up the bare necessities for the rest of the stages:
- Install the XCode Command Line tools
- Configure git account info for github.com
- Clone the dotfiles repository
- Install Homebrew
xcode-select --install
If you are not Friðjón, change this to your info
git config --global user.name "Friðjón Guðjohnsen"
# Redacted to protect the innocent
git config --global user.email "*******@gmail.com"
git config --global github.user fridjon
git config --global core.excludesfile ~/.gitignore
echo .DS_Store >> ~/.gitignore
git clone https://github.com/fridjon/dotfiles
# Hide the dotfiles folder so it does not show up in finder
chflags hidden dotfiles
Install Homebrew
# Will prompt for password and requires [enter]. Also need to run two manual commands that are output
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Allow apps downloaded from anywhere before installing with Brew
sudo spctl --master-disable
This stage sets up the shell environment in a nice and pleasing way. Firs
cd ~/dotfiles
brew bundle --file brews/Brewfile-base -v
# dotnet-sdk requires password, expressvpn requires password, msodbcsql requires YES, mssql-tools requires YES (twice)
brew bundle --file brews/Brewfile-frameworks -v
brew bundle --file brews/Brewfile-apps -v
brew bundle --file brews/Brewfile-docker -v
Run settings.sh
to apply custom preferences for Finder, Menu bar, Dock etc.
These settings are what is most likely to break as the preferences and corresponding files change between Mac OS versions. To be safe, skip running this script (except the last osascript step in the file that updates the look of terminal.app) and change settings manually.
Also note that the github repo https://github.com/mathiasbynens/dotfiles contains a lot of like minded tweaks.
cd ~/dotfiles
chmod +x settings.sh
./settings.sh
Set preferences for iTerm2
defaults write com.googlecode.iterm2.plist PrefsCustomFolder -string "~/dotfiles/iterm2"
defaults write com.googlecode.iterm2.plist LoadPrefsFromCustomFolder -bool true
Install Oh-My-Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Source the ZSH profile and other config files (optionally restart Terminal/iTerm2 after creating the symlink)
# Symlink neofetch config and .vimrc
touch ~/.hushlogin
mkdir -p ~/.config/neofetch
ln -svf ~/dotfiles/neofetch/config.conf ~/.config/neofetch/
ln -svf ~/dotfiles/.vimrc ~/
# Symlink .zshrc
ln -svf ~/dotfiles/.zshrc ~/
source ~/.zshrc
If you get compaudit insecure directories error run:
compaudit | xargs chmod g-w
compaudit | xargs chmod o-w
###########################
If you are on Apple silicon you might want to install Rosetta 2 in order to run x86 code by emulation. This is also needed for certain dockers only available as x86, most notoriously SQL Server.
softwareupdate --install-rosetta
TODO: Add stuff to configure docker to use Rosetta2
With 1password installed I get my SSH-keys from saved documents and move to ~/.ssh
and make sure permissions are correct
chmod 600 ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa.pub
chmod 700 ~/.ssh
If you have not created a ssh key, or wish to create a new one you can do that with the following.
cd ~/.ssh
ssh-keygen -t ed25519 -C "*****@gmail.com"
Create ~/.ssh/config
and modify it to automatically load keys into ssh-agent and store passphrases in keychain.
touch ~/.ssh/config
# Add to following to the config file
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
Add the private key to the ssh-agent
and store the potential passphrase in the keychain.
ssh-add --apple-use-keychain ~/.ssh/github-220305
If the public SSH-key has been added to GitHub, the connection can be tested
ssh -T git@github.com
Setup ~/.gnupg
folder from backup, checkout this gist for how to GPG.
gpg -k --keyid-format LONG # Copy the key for next step
git config --global user.signingkey <KEY>
git config --global commit.gpgsign true
git config --global gpg.program $(which gpg)
echo "pinentry-program /usr/local/bin/pinentry-mac" > ~/.gnupg/gpg-agent.conf
echo "use-agent" > ~/.gnupg/gpg.conf
Run settings.sh
to apply custom preferences for Finder, Menu bar, Dock etc.
These settings are what is most likely to break as the preferences and corresponding files change between Mac OS versions. To be safe, skip running this script (except the last osascript step in the file that updates the look of terminal.app) and change settings manually.
cd ~/dotfiles
chmod +x settings.sh
./settings.sh
Set preferences for iTerm2
defaults write com.googlecode.iterm2.plist PrefsCustomFolder -string "~/dotfiles/iterm2"
defaults write com.googlecode.iterm2.plist LoadPrefsFromCustomFolder -bool true
Install Oh-My-Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Source the ZSH profile and other config files (optionally restart Terminal/iTerm2 after creating the symlink)
# Symlink neofetch config and .vimrc
touch ~/.hushlogin
mkdir -p ~/.config/neofetch
ln -svf ~/dotfiles/neofetch/config.conf ~/.config/neofetch/
ln -svf ~/dotfiles/.vimrc ~/
# Symlink .zshrc
ln -svf ~/dotfiles/.zshrc ~/
source ~/.zshrc
If you get compaudit insecure directories error run:
compaudit | xargs chmod g-w
compaudit | xargs chmod o-w
Install latest Ruby version and colorls
for colorful ls
with icons. Aliased to lc
and lcc
rbenv install $(rbenv install -l | grep -v - | tail -1)
rbenv global $(rbenv install -l | grep -v - | tail -1)
Restart your terminal before installing gems
gem install colorls
With pyenv
installed, get the latest version of python
PYTHON_LATEST=$(pyenv install --list | sed 's/^ //' | grep '^\d' | grep --invert-match 'dev\|a\|b' | tail -1)
PYTHON_CONFIGURE_OPTS="--enable-framework"
pyenv install $PYTHON_LATEST
pyenv global $PYTHON_LATEST
pip install --upgrade pip
Setup Node with nvm
mkdir ~/.nvm
# nvm needs python 2.7
pyenv install 2.7
pyenv shell 2.7
nvm install 16
nvm install 18
nvm alias default 18
nvm use default
Install global packages from npmfile
cat ~/dotfiles/npmfile | xargs -L1 npm i -g > /dev/null
I sync plugins and settings to Visual Studio Code with the Settings sync plugin. It requires a GitHub API Token with gist access. Check out the configuration instructions. I store my GitHub API Token in a secure note with 1password.
My currently configured plugins can be found with:
curl -s https://api.github.com/gists/8b47741d950a86e46222eb8bfc293a9a \
| jq '.files."extensions.json".raw_url' \
| tr -d \" \
| xargs curl -s \
| grep name
I keep some config files, shell aliases and application preferences in a private branch of this repository and copy them into their designated destination after installing the apps. These files might contain Software Licenses, network addresses and other private data.
Here's a list of other software that doesn't have a homebrew package
Adobe Lightroom
Adobe Photoshop
Canon EOS Utility
Run these commands regularly to stay up to date
# Brew upgrade, update and cleanup
bubu
# npm update
npmu
Thanks to the dotfiles community and the creators/contributors there. Many of the aliases, settings etc. are borrowed from the repositories found there.