Chezmoi: manage your dotfiles securely across multiple machines
github.com
github.com
- use the same source file with different results for different machines (eg. .gitconfig for home and office machines)
- option to store secrets in a credentials database and extract them from there (because you wouldn't want to store them in a git repo - even if it's a private one)
I'll definitively give it a try!
(EDIT: formatting)
> - use the same source file with different results for different machines (eg. .gitconfig for home and office machines)
I do that by storing each machine's copy with its hostname as a suffix and symlinking it into place on each machine. e.g. ~/.config/anacrontab.systemA gets symlinked to ~/.config/anacrontab on systemA, and the repo contains both ~/.config/anacrontab.systemA and ~/.config/anacrontab.systemB. I can even modify one machine's file from the other machine, and it will be updated on the next push/pull.
But having integrated support for this would be nice.
https://developer.atlassian.com/blog/2016/02/best-way-to-sto...
data:
category: "linux-server"
in your .config/chezmoi/chezmoi.yaml file, you can then use it in your templates and a .chezmoiignore file (which is also treated as a template). A .chezmoiignore file could look like: {{ if eq .category "linux-server" -}}
.windowmanager.conf
{{ end -}}
I use this technique myself: https://github.com/twpayne/dotfiles/blob/master/.chezmoiigno...I'll definitely try it out!
Êtes-vous Français?
I have about 7 different machines/VMs/VPSes/partitions I use semi-regularly, so it's nice to have the exact same setup I use everywhere.
I also don't want to have to re-create my setup every time because I won't remember all the tweaks I set up months or years ago. I'm not the kind of user who constantly tweaks their configs, I've been using basically the same configs for about three years.
I'm the same way, and I have a similar setup. I have a public git repo with all of my custom git, vim, tmux, etc configs. It serves 2 purposes for me 1. make it easy to setup a new machine (literally run 1 command) and 2. provide a way to automatically backup configs for any machine I am on.
Everything I work on is either in git, dropbox, or I don't care about it. My goal is that I should be able to lose any computer I am working on, and be back up and running within a day.
I’m not the parent, but, yeah, this. I don’t have many machines that I need to connect to, but I make sure to sync my dotfiles to each of them. This gives me:
- A different shell prompt on each machine, so I’m less likely to type a command into the wrong one.
- Consistency in my shell aliases, so I never have to see “bash: ll: command not found” again. I have a lot of these, and I’d rather deal with syncing my dotfiles than re-mapping my muscle memory.
- All the helper scripts I’ve written over the last few years, so if I want to write a command and have it available everywhere, all I need to do is put it in a folder and wait for it to be synchronised.
I’ve been doing this for ages so I might be blind to some of the drawbacks, but I really like having the same terminal environment when I have to SSH somewhere else.
- Security. You don't need to store any secrets in your dotfiles repo, and instead delegate secret storage to LastPass or Bitwarden or similar.
- Fine-grained control of small differences across machines, accounts, and operating systems. For example, I want my ~/.zshrc to be roughly the same between my personal macOS laptop and my work Ubuntu server, but I need a few differences between them due to email address, paths to binaries, and OS-specific configuration.
I want a command that inspects every file and directory monitored by chezmoi in the target state and updates it in the source state. Specifically:
- New files in tracked directories should be listed with the ability to import them individually (presently you can only do `chezmoi add -r` and deal with the consequences).
- Adding files should respect the `chezmoiignore` file (I never want `chezmoi add -r ~/.config/fish` to import my `fish_history` file).
In the short term, to chose files individually you can do:
find ~/.config -type f > file-list
$EDITOR file-list # remove the ones you don't want imported
xargs chezmoi add <file-list
EDIT: Issues created: https://github.com/twpayne/chezmoi/issues/123 https://github.com/twpayne/chezmoi/issues/124Like some of the other commenters here, I use git branches for different setups, though in practice there's only really the one.
I also wrote a shell script (Dotty) [1] to 'collect' and 'deploy' dotfiles mixed freely with shell commands. Mixing shell scripting in lets me do things like remove unwanted files from my .emacs.d/ after collection, preserving nested directory structures, or any other pre- or post-collect/deploy arbitrary actions.
`git clone .`, `git-crypt unlock`, `stow --no-folding`, done.
I ended up writing my own in Bash about 7 years ago as a way to bring my Bash skills up to snuff. Was well worth it, even if there are good solutions out there. Probably could use some shell hardening and other maintenance, but it works well enough for my use.
My home folder is a Git repo and it works great. No complicated setup. Easy to sync remotely and track changes.
The advantage to Chezmoi (or GNU Stow) is that it can handle things outside of your home directory too (if I understand correctly).