Skip to content

Instantly share code, notes, and snippets.

@jviall
Last active January 14, 2026 19:56
Show Gist options
  • Select an option

  • Save jviall/dd5bbb4c2bb4f72690481a99bfbaf5e0 to your computer and use it in GitHub Desktop.

Select an option

Save jviall/dd5bbb4c2bb4f72690481a99bfbaf5e0 to your computer and use it in GitHub Desktop.
## First let's download YADM using Homebrew
brew install yadm
## did it work? You can check out the docs at https://yadm.io
which yadm
## YADM, as well as many other dotfile managament tools, uses the same commands as Git such as checkout, add, and commit
## We can use `yadm clone` to get a dotfiles repo going. So let's create a new repo called "dotfiles" and then clone it
open https://github.com/new?name=dotfiles
yadm clone jviall/dotfiles
## great. Now let's check out what's in your home folder
ls -la ~
## what files and folders do you see? Some ones to look out for are:
# .zshrc
# .zshenv
# .zprofile
# .gitconfig
# .config/
# .ssh/
## You probably have a .zshrc, one of the most common files you'll see in a dotfiles repo, so let's join the club
yadm add ~/.zshrc
## now let's see what happened
yadm status
## we can see that it started tracking our .zshrc in our Dotfiles repo. Let's see it's contents
yadm diff
## if we're content with it, we can commit it
yadm commit -m "Add .zshrc"
## Are you a VSCode user? maybe you want to track your user settings. Let's open VSCode
code
# In the bottom left, click the Cogwheel icon, select "Settings"
# then near the top right select the file icon titled "Open Settings (JSON)"
# This is a representation of all your user-specific VSCode settings that different than the defaults
## We can track this file in our dotfiles repo.
yadm add ~/Library/Application\ Support/Code/User/settings.json
yadm commit -m "Add VSCode user settings"
## Great, we've got a couple files tracked in our dotfiles, let's make sure they're pushed up
yadm push
## Next let's tackle the second-most common dotfiles need--bootstrapping.
# Most people need to do a handful of things when first setting up a new machine
# Things like installing homebrew and preferred apps, changing default OS settings, downloading plugins, etc.
# YADM, like many other dotfile managers, supports this kind of work out of the box.
code ~/.config/yadm/bootstrap
## the ~/.config/yadm/bootstrap is a special file recognized by YADM. when we run `yadm bootstrap` this file will be executed.
# See https://yadm.io/docs/bootstrap
# We can use it to accomplish tasks we need to do on every new machine such as:
#####################################
#!/bin/zsh
# ~/.config/yadm/bootstrap
# install homebrew if it's missing
if ! command -v brew >/dev/null 2>&1; then
echo "Installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# and install/update a global list of applications if it exists
if [ -f "$HOME/.Brewfile" ]; then
echo "Updating homebrew bundle"
brew bundle --global
fi
# Maybe configure some opinionated OS settings like:
# hide the dock
defaults write com.apple.dock autohide -bool true
killall Dock
# fast key repeat rate, requires reboot to take effect
defaults write ~/Library/Preferences/.GlobalPreferences KeyRepeat -int 1
defaults write ~/Library/Preferences/.GlobalPreferences InitialKeyRepeat -int 15
# set finder to display full path in title bar
defaults write com.apple.finder '_FXShowPosixPathInTitle' -bool true
# Or install some fancy shell tools like OhMyZsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
#####################################
## After installation, homebrew prompts you to add some stuff to your .zshrc
# if yours doesn't already have this or something similar you should add it!
eval "$(/opt/homebrew/bin/brew shellenv)"
# Once we have some bootsrapping steps, let's test it out. First make sure the file is executable
chmod +x ~/.config/yadm/bootstrap
# then let's run it.
yadm bootstrap
# the yadm bootstrap command runs the ~/.config/yadm/bootstrap if it exsits.
# YADM also conveniently runs any existing bootstrap command automatically after running `yadm clone`
# now that we have bootstrapping sorted out, let's add it to our dotfiles
yadm add ~/.config/yadm/bootstrap
yadm commit -m "Add bootstrap script"
# Up above, our bootstrap script referenced a .Brewfile. Let's make one
code ~/.Brewfile
#####################################
# ~/.Brewfile
# CLI commands
brew "zoxide"
brew "eza"
# Apps
cask "visual-studio-code"
cask "google-chrome"
#####################################
# and do our usual thing
yadm add ~/.Brewfile
yadm commit -m "Add a global Brewfile"
# We're ready to really put our dotfiles to the test. Let's push up our changes and start from scratch
yadm push
rm -rf ~/.local/share/yadm # deletes the dotfile repo
rm ~/.zshrc
rm ~/.config/yadm/bootstrap
rm ~/.Brewfile
# We could even uninstall brew to really test it, but for the sake of time and avoiding potential headaches, let's skip
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
# But wait a sec, if we installed YADM with homebrew, but we want to use yadm to setup new computers and install homebrew for us
# isn't that kind of a chicken + egg situation?
# Elementary my dear Watson!
# we can download YADM directly and clone our repo in a single batch of commands:
export DOTFILES="username/reponame" && mkdir -p ~/.local/bin && curl -sfLo ~/.local/bin/yadm https://github.com/TheLocehiliosan/yadm/raw/master/yadm && chmod a+x ~/.local/bin/yadm && ~/.local/bin/yadm clone "https://github.com/$DOTFILES"
# And Voila! everything we just did is back to how we like it. It's a good idea to take the above command, and put it in a README file
code ~/README.md
yadm add ~/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment