Need optimization? Dotfiles to the rescue!
Dotfiles are a user-configured repository that allow for customization of a development environment. These custom scripts run inside bash, zsh, or other shells and extends functionality of other softwares like git or tmux. Dotfiles are a basic necessity for every developer, yet many github profiles do not have them. Ever since I started my dotfiles, I have been hooked.
What Exactly Are Dotfiles?
- Normally tracked in a git repo.
- Hooks into your PATH variable (try typing
echo $PATHin terminal).
- Can track your software installs (Chrome, Spotify, VIM, node, etc.).
- Allow you to define aliases (“git commit -a” can be “gca”).
- Countless other things.
How do I Start Using Dotfiles?
I first discovered the wonders of dotfiles when I read Dotfiles Are Meant to Be Forked. After looking at a few dotfiles, I decided to fork from Holman. The README documentation will have you up and running in under 10 seconds! The forks are also very useful for finding ideas that you can steal… I mean borrow.
Ready for the warm fuzzy feeling of a snowy Christmas morning? This is how I felt when beginning to use dotfiles.
Start by exploring around in your newly cloned repository. If there is anything that you have been dying to have, add it! To show you how arbitrary (and awesome) you can customize, let us see a snippet from OmeGak.
# minecraft/aliases.zsh alias mci="minecraft start" alias mck="minecraft stop" alias mcr="minecraft restart" alias mcu="minecraft update" alias mcb="minecraf backup" alias mcs="minecraft status" alias mc="minecraft command"
Great for Minecraft admins :). Likewise, some of my most used aliases are:
gac "<<insert message>>" is git add -A && git commit -am "<<insert message>>" gp is git push origin HEAD fig is docker-compose $* e opens atom with the current directory as the workspace pu is pg_ctl -D /usr/local/var/postgres start pd is pg_ctl -D /usr/local/var/postgres stop # You can find these in: # - git/aliases.zsh # - docker/aliases.zsh # - bin/e # - postgres/aliases.zsh
By shortcutting your lengthy commands, you can save a ton of time! Assume you can save 4 seconds for each command you use, and let us assume that you run 25 commands each day. This is being pretty conservative.
The amount of savings:
4 (seconds of savings) * 25 (commands per day) * 261 (work days per year) = 26,100 seconds per year = 7.25 hours of extra time per year
Reimaging your computer
Now that it is springtime, I would say that it is time for some cleaning. I just recently reimaged my Mac and was able to get up-and-running in minimal time. In fact, the limiting factor was the internet speed!
The software that I need is baked right into my dotfiles. Let us have a look.
# Brewfile cask_args appdir: '/Applications' tap 'homebrew/bundle' brew 'coreutils' brew 'go' brew 'jp2a' brew 'libgit2' brew 'openssl' brew 'node' brew 'postgresql' brew 'roundup' brew 'wget' brew 'yarn' brew 'youtube-dl' brew 'ctags' brew 'vim' brew 'tmux' brew 'gpg' cask '1password' cask 'adium' cask 'firefox' cask 'google-chrome' cask 'slack' cask 'transmission' cask 'vlc' cask 'spotify'
# node/install.sh if test ! $(which spoof) then sudo npm install spoof -g fi if test ! $(which gulp) then sudo npm install gulp -g fi if test ! $(which mocha) then sudo npm install mocha -g fi if test ! $(which bower) then sudo npm install bower -g fi if test ! $(which eslint) then sudo npm install eslint -g fi
Though I could list a couple different install scripts, I think you get the point. With all of these scripts, how do I install them in succession? Holman makes it very easy!
./script/install && ./script/bootstrap
Now I am up and running on a fresh computer! Say goodbye to manually brew installing and npm installing. Plus, this will give you more consistency across your development environments.
Consistency is very important since I develop on many different machines. My favorite editor, VIM, makes up the majority of my dotfiles. This tracks:
- Plugins (submodules to stay up-to-date with the newest versions)
- Custom Snippets (a great alternative of plop or Yeoman)
- .vimrc (obviously)
You Can Do Anything
This post scratches the surface. The power of dotfiles is only limited by your imagination (and the imagination of others).
If you have any questions or want to show me your awesome dotfiles, let me know @Jake_Robers!