Ask HN: How do you sync your computer’s development configurations/environment?
Since I knew that I will be using different IDEs and environments, I decided to learn vim and use vim bindings in all my IDEs to ensure some sort of similarity across all my development environments, but it doesn't cover it all. I've also tried manually migrating my home directory between different computers, but that comes with several issues, primarily that I'd have to try to share it between professional and personal computers. So what I'm left with is basically remembering what I'm using, and then tediously spend a day or more re-configuring newly installed computers with the software and configurations I know I'm using. It feels like I have to throw away my perfectly configured hammer which I know by heart and get a new one every time I work at a different workplace instead of bringing it along and perfecting it further. Surely there's a better way.
How do you keep your development environments/ways of working synced and backed up?
152 comments
[ 4.7 ms ] story [ 198 ms ] threadThe files you're managing don't even need to be text, though, of course, it makes versioning, etc. a lot easier.
I also check the host name in some of the scripts to modify behavior depending on the machine.
I did a write-up about my whole setup (emphasis on GNU Stow + Git) here:
https://ratfactor.com/setup2
[1]: https://syncthing.net/
Might be bad of me, but I definitely share it between professional and personal - it's just dotfiles after all.
The biggest difficulty is making sure that the installation script actually matches what you want to happen because it is difficult to test on already finished system. so every so often I spin up a Digitalocean droplet and try to configure my system from scratch using the dotfiles.
https://github.com/kesslern/dot-templater
[0] https://www.cis.upenn.edu/~bcpierce/unison/
For example, let's say an app has a default keyboard shortcut I don't like. I won't change it. Instead, I'll just get used to it until it becomes muscle memory.
Now the default configurations are my preferred configurations. Of course, there are still a few things I change from the defaults. But since there are so few I can just configure them by hand, because how often am I setting up a new computer? Not very often. And there are so few config changes, it only takes a minute.
The only thing I have to actually sync is my vim config. It's a very small config, but it's still more than nothing. I just store it in a Git repository.
Most configuration stuff doesn’t fit that category - or if it does, it’s best to first work on just caring about it less if possible.
I have even written a short essay, as I found myself repeating the same suggestions many a times. https://notes.oinam.com/digital/apple/
I guess my personal strategy is to run with the defaults until you find the pain points, and install/configure something to address them. And put them in git repo if possible.
I don't use any plugins for PyCharm or IntelliJ, but they're pretty full-featured right out of the box. I certainly don't do it as a badge of honor, that indeed is pretty silly.
But vim is useless without any plugins. Even VSCode is only marginally better than Notepad++ unless you give it the plugins necessary to turn it into an actual IDE and not just a code editor.
It’s not? I mean vim defaults are great, it supports a lot of formats out of the box (indentation, syntax highlighting), it’s ideal for quick edits. Surely if you need an IDE-like functional then it’s not enough (probably) but it is very far from being useless without plugins.
Use the GUI settings panel to make CAPS LOCK an extra ctrl. Takes maybe 10 seconds.
Use same to make dock auto-hide. 10 seconds if I'm slow about it.
Install Homebrew. Maybe 15 seconds hands-on and a couple minutes in the background.
Use Homebrew to install spectacle. Less than 5 seconds hands-on time, done less than a minute later.
Start Spectacle and use its preferences panel to set it to start on boot. Maybe 15 seconds.
Remove all the pinned programs on the dock. 60-90 seconds.
The last one's the only part I've considered scripting, but since I only do it once every couple years at most, it's not really worth it.
Once I'm past a Mac's initial "welcome to Mac" flow and on the actual desktop, I'm only about 5 minutes (not all of it actively doing things) from having a comfortable environment set up and being all ready to install project-specific tools, as needed.
If I ever switch back to Linux (or FreeBSD, which is more likely at this point) I might go back to versioning and backing up a bunch of config and dot files. I need them, there.
Another fine specimen, salute!
I have a udev rule that does the ESC mapping, but will have to try harder to see if I can make it do that on Linux.
Cmd-Opt-D to toggle auto-hiding – I use this one to check if the dock is frozen :)
(Also a great option to rebind: it's a global hotkey so no other app should be using it)
Almost every linux box has bash, vim, and the GNU command line tools. If you can become proficient with default config cli tools, you can become proficient on almost any linux box.
This is the worst advice you could give. There are plenty of shitty defaults and default tastes vary from app to app and there's a reason things are customizable.
Customize to your taste throughout your tools and don't let a new tool eat your time.
I do keep my ~/scripts/ directory in a git repo (also this directory is in my $PATH) because they're all very hack and slash "I need to do a thing repeatedly, quickly" scripts. Sometimes I might want to go back a step or two when I really break everything. This repo auto pulls/commitpushes every now and then as this one is more useful to be up to date on all machines than to have useful commit messages
As for live syncing devices I do have unison running on my laptop frequently to sync (when its on) a few directories I might need offline. Mostly everything I need as a dev is in git repos though, so I use manual git push/pulls to sync everything else
I did previously use mackup (https://github.com/lra/mackup) to sync configs but if I'm honest I forgot I had it set up the last time I reinstalled so it got removed from the process unintentionally
Couple of bits from a guide I wrote recently: https://gist.github.com/aclarknexient/0ffcb98aa262c585c49d4b...
That OSTYPE is great for all those little bits that are unique to each operating system. The zshenv-local is in .gitignore, so you can keep tokens, api keys, etc etc in there. OSTYPE could even be used to import specific files like .zshenv-darwin or .zshenv-linux-gnuIf you're ssh'ing between your hosts, you can use something like this:
It's not fancy and doesn't use cool tools, but my setup works for me just fine.I'm gonna go though your guide later though-- I like quite a bit of what I've skimmed so far. Thanks for posting that.
EDIT: and that "*" for gitignore is intriguing, I'll have to take a better look at that whitelist vs blacklist setup, thank you!
Then for more systemwide configuration, I have an Ansible playbook I run every now and then (configures apps, dock item order, etc): https://github.com/geerlingguy/mac-dev-playbook
https://github.com/lra/mackup
Right now all my computers run fedora so there's not much difference between them but for some time I used Ansible on macOS too. It worked but was a pain to make my roles compatible for both linux and macOS.
In my experience Ansible is good when dealing with text files or if there's already a module for what you're trying to do (for example managing postgresql users). If what you're trying to do is complex enough that you need to write a custom module or plugin, it is a pain in the ass: we had to do that at work and it was terrible.
Ansible works on Windows but I have no experience with it.
I'm able to have the same shell with all my Vim plugins across macOS and Linux with changes committed to git. It's been so good, setting up all my command-line tooling now takes about 15 minutes from scratch.
- `git clone` said repository to my machines
- `ln` from repository folder to `~/` (can be done in an install script or piecemeal)
- `git pull` to update
I also purposely try and use as many default configurations as possible. I use a lot of remote machines that do not have my configs on them, so I do not want to become too reliant on custom setups.
All that said, if I was starting today I would strongly consider just putting everything into nix with home manager and carry that config around in a git repo that installed my packages and their configuration and encapsulated my entire environment.
[0] https://github.com/jvsg/stow-simple
This allows me to abstract logic easily, have it all modular and have everything be nix.
It's more or less a wrapper of git, but it comes with a bunch of features that allow you to do the things you describe.
[0] - http://www.gnu.org/software/stow/
But there were a few problems with it: - installed packages needed to be managed separately (the mechanisms for which varied by platform) - managing differing configs for different machines (e.g. headless servers, hardware quirks) was done by managing different branches of this repo and rebasing, which was a pain - it was generally brittle and hard to change
I've started to use https://nixos.org/ and it's been like night and day: https://github.com/RyanGibb/nixos/
My config is version controlled, reproducible, manages packages, and is very composable.
Using the nix package manager and https://github.com/nix-community/home-manager this should work on other Linux distributions, MacOS, and even Windows Subsystem for Linux. Although I haven't tried this for myself yet.
That's work VERY well, but might not fit your needs depending on what you need to use for work...
I'm another one using a private GitHub repo for this. But I don't need to pull, update, sync or whatsoever. I've been using the same config for years, and in the eventual case that I would change / add something, I can do that quickly in a few computers, no need to have any sort of sync.
For VSCode settings I just use the built-in service.