Noteworthy Dotfile Hacks

March 10, 2015

I have hundreds of files and folders in my dotfiles repo, and nearly 1000 commits—there are quite a few hidden gems buried in there that generally don’t get to see the light of day. Rather than wander aimlessly through them, let me give you the guided tour.

I often tell people “oh, and you can also go check out my dotfiles repository for more cool configurations” when I’m giving out dotfiles advice. If someone gave me this advice, I know I wouldn’t follow up, even if I had the utmost awe for the recommender. Drudging through config files isn’t all that fun, even though they can do fun things. Why not get rid of the drudgery?

This post is designed to bring the coolest parts of my dotfiles to the top. It’s organized by topic, so feel free to skip around.

Note: throughout this post, I’ll be linking to my dotfiles at a specific commit on GitHub. While this solves the problem of line-level links breaking on updates, it means that you’ll almost certainly be looking at out-dated code. Make sure to check out the corresponding file on the master branch for the most up-to-date version.

Also, I just wrote about one of my biggest dotfile hacks: using rcm to keep my dotfiles in sync across machines. Be sure to give it a read if you’re running into that problem.

tmux

I have a lot of cool stuff going on in my .tmux.conf

  • I bind the prefix key to C-f, something which I haven’t seen many people do. I’ve never had a problem with it conflicting with commonly used shortcuts, and it’s incredibly easy to press (compared with the common options of C-a and C-b)
  • I integrate with two Vim plugins:
    • vim-tmux-navigator, which lets you jump between vim splits and tmux splits as if they were the same thing
    • tmuxline, which makes my tmux status bar look just like Vim with vim-airline (it even pulls down the colors from your Vim configuration!).

dircolors

I use the GNU dircolors command to change the colors output by the ls program. After running brew install coreutils on OS X, I’m able to see the colors thanks to this file and this snippet in my zshrc.

(image from the dircolors-solarized repository on GitHub)

gitconfig

I talked about this in a previous post, but I have some special settings in my global gitconfig for adding colored decoration to git log commands. Here’s a screenshot from that post:

aklog cs.cmu.edu

For my friends at CMU, I have aklog cs.cmu.edu in my ~/.zshenv, which gets run even when you log in interactively (like what happens when you scp something), so that I can copy files from my local machine to the SCS AFS space, which is useful for doing things like making handins. Note that the file linked to above is a host-specific file that only “exists” for me on Andrew machines. You can read more about my setup in my previous post.

zsh-syntax-highlighting

I use a zsh plugin to syntax highlight my commands as I type them on the command line, similar to how the fish shell does it. It does various things, like coloring the command red or green based on whether it exists, underlines filenames that exist, highlights filenames that might be misspelled in yellow, highlights built-ins like if and for in orange, etc.

Here are some examples from my setup:

Automatic Dotfile Updates

I wrote a pretty robust script that reminds me to update my dotfiles and my system regularly. All it does is remind me to check for system updates once every 24 hours, but it works so well that I had updated my system bash version before I even read about Shell Shock!

The relevant links are here for the core script that I source in my zshrc, and then the following host specific links:

  • here for my MacBook
  • here for my Ubuntu VPS

Shell aliases

I’d like to think that my whole aliases.sh file is golden, but if you’re looking for some specific things I like about it, check out my git log aliases, which I wrote about here, and my chromemem alias, which I wrote about here.

Ruby Virtualenvs

I wrote about how I use Python Virtualenvs to sandbox Ruby gems, a post in which I dropped some snippets that you can use to configure virtualenvwrapper to work with Ruby projects. I actually went ahead and fed those files right into rcm, so they’ll always be available if I ever get a new laptop.

ssh

My hostname on every machine I ssh to for school is jezimmer, but there are countless servers I can ssh into (7 for unix.andrew.cmu.edu, 99+ for ghc*.ghc.andrew.cmu.edu, 10 for 15-213, the list goes on). These lines enable me to ssh to any of those machines with just a hostname, and the username is assumed to be jezimmer.

iTerm2

There’s not much to show for this one, but in Preferences > General of iTerm2, you can opt to load your iTerm2 preferences from a specific location. I’ve set this to /Users/jake/.dotfiles, which means that my iTerm2 settings are always written to my .dotfiles/ directory. If I ever make changes to iTerm2, they get propagated as changes that Git picks up on and which I subsequently check into Git history.

Vim

I’m in love with my Vim setup. If you’re looking for help getting started configuring Vim, you should checkout the Vim plugins workshop I put together, which gets you started with a “fully-configured” Vim setup. Once you think you’ve “mastered” that and you’re ready for more, here are a list of things I’m proud of in my .vimrc:

  • set breakindent A feature new in Vim 7.4, this allows you to align wrapped text at the same indentation level as the preceding text.
  • these mappings, which let me move around (move up and down in particular) in long lines just as if they were short.
  • this mapping, which lets me open Vim help pages in new tabs

Other

I’ve only highlighted a fraction of my configuration files, but I think I’ve managed to capture a good portion of them. If you thought that one of these snippets was useful, are having trouble getting something to work, or have something interesting to share, leave a comment below!


Jake on the Web

If you cared enough to read that far, you should consider following me on GitHub or paying a visit to my homepage. If this post was about one of my open source projects, make sure to star it on GitHub! I love hearing what people think, so feel free to open an issue or send me an email.

Haskell Development with Neovim

After a year and a half of using Haskell on and off, I’ve finally settled on a set of high-quality development and editor tools, using Stack and Neovim. Continue reading

Reach for Markdown, not LaTeX

Published on February 26, 2017

Troubleshooting Haskell Stack Setup on OS X

Published on August 03, 2016