Mission: dot files

Mission: dot files

Since I began working, I've had people I worked with talk about their development environment and how they have aimed to make their process of picking up a user story and getting it finished, more streamlined. Some of the main traits that I've seen with these people are their desire to constantly learn and grow. Isn't afraid to fail and has dot files. Having dot files is a great way to share your settings between like environments.

What are dot file projects?

Dot file projects are usually a collection of commands that help setup your computer on a fresh install. This can contain various "dot" files for a wide range of applications. Some that might be familiar are .gitconfig,  .zshrc,  .eslintrc, and Brewfile.

How do I get started?

This was hard for me to answer for myself. Most of the dot file projects I looked at were intense. There was a lot of configurations and a ton of commands I hadn't even begun to understand. If you are asking this question it's likely your experience with linux is basic.

That's alright. I was too.

If you are fine with parsing lines and lines of config references, then finding a dot project online might be the best choice. I on the other hand wanted to know how you would go about making one first. So I started with homebrew.🍺

I use homebrew on my mac for everything that I can. It really streamlines my app and tool updates. I don't have to deal with searching for the app online and working my way past ads or email signups to install an app. I can just brew search appName and follow up with a brew cask install appName or brew install toolName.

Once you have a bunch of apps installed on your machine, it would be kind of nice to backup that list.

Enter stage left homebrew-bundle

Dump 🚯

If you don't know about this plugin, quick run brew bundle dump before a freak surge happens and you lose all data on your device. (Not that it is going to help but at least you know the last command you ran before it died. How thoughtful.)

After running the command above, this will generate a Brewfile in your current or home directory. You can open it up and see what it contains. It should look something like this:

tap "homebrew/bundle"
tap "homebrew/cask"

brew "bat"
brew "curl"
brew "ruby", link: true
brew "tree"
brew "vim"
brew "watch"
brew "yarn"
brew "z"
brew "zsh"
brew "zsh-completions"

cask "1password"
cask "alfred"
cask "dash"
cask "discord"
cask "docker"
cask "font-fira-code"
cask "font-firacode-nerd-font"
cask "iterm2"
cask "spotify"
cask "spotify-notifications"
cask "visual-studio-code"

mas "Airmail", id: 918858936
mas "Amphetamine", id: 937984704
mas "Boom 2", id: 948176063
mas "Fantastical", id: 975937182
mas "Xcode", id: 497799835

Now we aren't quite to the point of automating this stuff. But we are close. First, we need to back this stuff up. What better place than github?! (Or keybase, bitbucket, gitlab, or a homelab running a git server)

Once that project is created and you have cloned it down onto your computer. You will then want to move that fresh Brewfile somewhere in that git project. If you want to take a look at how I did mine you can do so here. While we are at it we will want to create some file that will be your entry point into this whole process.

touch install.sh; chmod +x install.sh

Your fresh dotfile project should now look like this:

My-Dotfiles/
  Brewfile
  install.sh

Automate

Now that we have this, there are two parts that will get you started on the path of a dotfile project.

  1. When the main install command file is ran, it symlinks your Brewfile to ~/Brewfile.
  2. It then runs brew bundle

This will make it so you can make changes or run another dump and be able to back up those changes sometime in the future.

The command I use to link my brewfile is as follows

link_file(){
  print "Linking $1"
  ln -s $PWD/$1 $HOME/$1
}

This translates to:

ln -s currentDirectory/Brewfile ~/Brewfile

You can put this at the top of your install.sh file.

Next we will want to run brew bundle. So do that. It's just that easy. Place that command in your install.sh file right after the first command.

Onward

You are well on your way to creating your dotfile project. There are a bunch of things you can do with the project. For mine, I really liked how oh-my-zsh would check for updates every so often. So I built my own brew updater that would run every so often and give me the choice to run it then or abort for another x amount of time. This makes it so I don't have to worry about security updates and all my apps and tools update to the latest and greatest at a set interval.

Another Idea I had while I was writing this post, would be to make it so it would alias these commands so you can run them from where ever. Or have it prompt you every so often to backup your dot files. Try to make the process as seamless as possible.

Need other ideas?

Homebrew is just the start. I use dotfiles for actual dotfile work. Take a look at my project here. I have two .gitconfigs because I split my work projects from my personal projects in my git folder. This makes it easier for me to be able to sign my commits using my work PGP key and then use my personal PGP key for when I am working on personal things. (I also use Keybase for managing my PGP keys) I even use dotfiles for setting up my mac preferences using their plist commands. The possibilities of this are pretty much endless.