Managing Local and Remote Dot Files
October 29, 2016
This post describes how I like to think about and manage the dot files on both my local macOS dev machine, as well as any remote Linux server I use regularly – in one single setup.
TL;DR: Check out my dot files repo for the code. To get started you can just clone/fork and run one of the setup scripts.
My Dot Files
We all love dot files. A lot has been written about them, and there are many popular GitHub repos with cool examples. What makes mine different is the fact that I like to take them with me everywhere I go, including when SSH-ing into any server – both for work and personal use – even for the ones I’ve never used before!
They serve two purposes for me:
- Not being attached to any particular dev machine – I rely on my dot files and the various setup scripts for a very quick ramp-up when moving to a new Mac.
- Having maximum convenience and productivity anywhere possible.
My dot files include a lot of the typical shell/tools setup:
- Shell1
- Vim
- Tmux/Screen
- Git/Mercurial
I also store the config files for some of my native Mac apps, including:
- Alfred
- Sublime Text
- IntelliJ
- iTerm
How It Works
My setup includes careful integration of the following:
- Using git to store and version all files.
- Precisely managing which dot file goes where.
- Supporting both local (macOS) and remote (Linux) dot files, while also reusing the common parts.
- Using the great sshrc script.
- Configuring
tmux
/screen
to work withsshrc
.
Setup includes cloning the repo locally2 and symlinking all files listed in links
.
When SSH-ing somewhere, I use the sshrc
command, which zips all files found in the ~/.sshrc.d
directory (also managed by links
), and extracts them to a temporary directory on the destination server. It then sources .sshrc
to configure everything.
Lastly, I use my custom screenrc
and tmuxrc
commands on the server to open new sessions. These make sure that new sessions are initialized with everything extracted by sshrc
.
Conclusion
This might sound complicated, but it works seamlessly and effortlessly. I no longer have to worry about keeping the various snowflake instances of my dot files on the various servers I use in sync, and I get to share a lot of the code that makes sense with my local Mac setup. I also don’t litter any server I connect to with local copies of my personal files since sshrc
uses tmp files and cleans up after itself.
Interested? Take it for a spin: https://github.com/orrsella/dotfiles
Have a cool addition? Fork and add! Send a pull request if you think I should include in my setup as well.
-
I only use bash. I find comfort in knowing that any environment I work with has bash, without relying a specific configuration – that’s out of my control – having other shells like zsh, fish, etc. I feel like my dot files make it so I get a lot of the convenience of using other modern shells while having a consistent experience everywhere. This doesn’t mean you have to do the same. ↩
-
I like to use
~/.dotfiles
. ↩