Readit News logoReadit News
dharbin · a year ago
I’m a big fan of chezmoi (https://www.chezmoi.io/) which is a very capable dotfile manager. Chezmoi supports some useful advanced capabilities like work/home profiles and secrets manager integration.
kstrauser · a year ago
Same for me. I'd done the same thing as the author with various methods like stow, symlink farms, etc. over the years. Chezmoi is good enough that I'm willing to let someone else handle maintaining all logic.
dngray · a year ago
Yup, I tried a number of dotfile managers. I think yadm was the first one I started with and then ended up with chezmoi.

The main reason was because I discovered the power of templating. With Yadm it required an external dependency, envptl, then j2cli, and both of these became unmaintained, while chezmoi used the text/template standard library. After the task of converting my jinja2 templates to gotmpl I never looked back.

One of the other things I like about chezmoi is I significantly cut down any "scripts" to just a few as most of the logic became "deterministic", ie I would set conditions based on the host in chezmoi.toml.tmpl and then that would define how everything under that would run across multiple hosts, and devices.

ashconnor · a year ago
I migrated to chezmoi recently my only gripe is `chezmoi cd` opening in a new shell but `chezmoi git` usually is what I need. The age [0] integration is nice.

[0] - https://github.com/FiloSottile/age

baliex · a year ago
I added an alias `cm='cd $(chezmoi source-path)'` to my shell config to cd to the chezmoi directory (without opening a new shell) so I can use all the usual commands (e.g. git) without need the chezmoi prefix. The alias is in a chezmoi-managed file, naturally.
twp · a year ago
Unfortunately there's no other way of doing this, except for adding a shell alias. See https://www.chezmoi.io/user-guide/frequently-asked-questions....
samgranieri · a year ago
Chezmoi is amazing. I dabbled with Stow, but Chezmoi is the way to go.
wyclif · a year ago
Hey, I had never heard about chezmoi before reading your comment, but I just installed it. Took less than 10 minutes to set up from start to finish. I noticed that if you choose to use it to manage your `~/.ssh/config/`, by default chezmoi sets it up as `private_dot_ssh/` and so if your dotfiles are public it doesn't expose sensitive data like private key files such as `~/.ssh/id_rsa`. Smart!
Arrowmaster · a year ago
The private_ only applies to file permissions so in this case it makes the .ssh directory only readable by the owner. This is checked for by openssh and the config will be ignored if it's readable by the group or all.

If you make your dotfiles repo publicly accessible, you will leak your private keys unless you use other features in chezmoi to protect them.

Barrin92 · a year ago
also a big fan of it because the templating feature makes it very easy to handle dotfiles with different locations on multiple machines and if you use multiple operating systems. Really not that many tools around that have good windows support.
dolni · a year ago
What happens when you need to link a file that does not support comments like that? For example, something which stores its config as plain JSON.

Or how about when you want to symlink an entire directory? For example something like neovim, considering that you may want to split config into separate files for organization. My neovim configuration has an "autoload setup" so any lua files inside the config directory are automatically required.

Lastly, this approach does not appear to support running commands. My dotfile install script ensures that tmux plugins are installed, the terminal font I use is available, and some other stuff that you need to invoke a command or script to achieve.

I like that the approach is simple, but I do not think it can support even relatively common use cases very well.

blueflow · a year ago
I'm not using a dotfiles manager, i track my ~/.config in git and have a script that globs for ~/.config/*/dot.* files to create symlinks for them. Like ~/.config/bash/dot.bashrc . Works with directories.
sandreas · a year ago
I prefer using ONE symlinked ~/.zshrc -> ~/dotfiles/etc/zsh/.zshrc and then using ENV-Variables within the .zshrc to specifiy other config file locations:

  # starship
  export STARSHIP_CONFIG="$HOME/dotfiles/etc/starship/starship.toml"

  # git
  export GIT_CONFIG_GLOBAL="$HOME/dotfiles/etc/git/.gitconfig"

  # vim
  export MYVIMRC="$HOME/dotfiles/etc/vim/vimrc"
  export VIMINIT='source $MYVIMRC'

  # ...
So one symlink is enough :-) Something similar can be done for ssh config (this file can not be symlinked for security reasons, so be careful working around this "feature"):

  # contents of $HOME/.ssh/config
  Include ~/dotfiles/etc/ssh/hosts.d/*

dansalias · a year ago
The JSON hiccup occured to me - I don't have any JSON dotfiles but I guess I'd store it as hjson (https://hjson.github.io/) and add a conversion step.

Symlinking a directory - admittedly didn't come up for my dotfiles, maybe `.ln` files with a similar format in dir roots.

Commands - yes, I still keep a set of shell scripts alongside my config files.

arcanemachiner · a year ago
Huh. Seems like an interesting alternative to JSONC.
MrDresden · a year ago
Sounds like a job for a personal Ansible playbook.
fmbb · a year ago
Every time I see these tools for “managing” dotfiles, or something for “managing” notes I get a bit perplexed as to what the use is, but then I am reminded of and impressed with how different people’s brains are and how we work and think.
Yasuraka · a year ago
I was getting by with bare git and then YADM until I grew tired of managing the logic to keep everything in sync across multiple machines and types or versions of OS, on top of managing my configs already.

https://www.chezmoi.io/user-guide/manage-machine-to-machine-...

SoftTalker · a year ago
I always think "managing dotfiles" is the path that leads to Windows Registry if you follow it too far.
viraptor · a year ago
Or if you follow just the right amount. Apart from the implementation issues, it's a great idea. MacOS essentially has a similar thing available through defaults.
heads · a year ago
What I realized after 25 years is that configuration comes in three parts:

1/ the defaults, either built in or read from /etc;

2/ my defaults, included in each file (or with ssh, at the bottom) with that particular config’s native version of #include; and

3/ local specifics that are rarely if ever used anywhere else, or trivially short as to be copy-paste-able.

Almost everything I want to customize goes into (2) so I wrote a single Python function that manages a block at the top (or with ssh, at the bottom) of each config file:

  # BEGIN my foo stuff
  include = /my/repo/foo/config
  # END my foo stuff
That way foo starts out with (1) the system defaults; then adds (2) my personal foo defaults as defined in a working copy at /my/repo; (3) anything else I insert in the file after that which isn’t centrally managed and that’s ok.

I haven’t ever needed anything more complicated. I do not have any work specific configs that I need to gate. I no longer have to manage different configs based on whether I am using Debian, Debian (old), Debian (very old), SunOS (very very old), or AIX (very very very old) because those days are behind me.

If you do still need to manage slightly different but ethereally different configs on different hosts then I’m sorry to hear that. Rationalising my computing life so that I use the latest version of some Linux distribution everywhere has been very helpful!

b3lm0nt · a year ago
I use Gary Bernhardt's (non)-method, quoted here:

IMO you don't need a special tool to manage your home directory / dotfiles. Git is the tool. Your home directory is a repo with a .git directory like any other repo. No other tools; no symlinks; nothing else. Commit what you want and gitignore the rest. I've done this since 2008.

Never had a problem with it.

JoshTriplett · a year ago
That's what I do as well. Since you can .gitignore entire directories, that makes it easy. And one major advantage is having `git status` tell you if new things show up, so you can decide whether to track or ignore them (or change how/whether they're created in the first place).
skinner927 · a year ago
One better, put a '*' in your .gitignore and then !.vimrc the files you do want to track.
sneak · a year ago
yadm implements this model, but also allows for machine-specific branching and encrypted secrets (no secrets should be directly committed in git).
effdee · a year ago
One version of this is to use a bare repo, as described in https://news.ycombinator.com/item?id=11070797
sciencerobot · a year ago
I switched to this method after using symlinks for years. This guide was helpful: https://queensidecastle.com/guides/tracking-your-home-direct...
jackhalford · a year ago
I just put dotfiles directly where they are and majr a .git directory in my $HOME. .gitignore everything and git add -f files when I need to. no symlinking or anything.
rfoo · a year ago
For those who are convinced and want a slightly more convenient tool for doing this: try yadm.
dngray · a year ago
As someone who used yadm, and switched to chezmoi, the main reason was templating was so much better in chezmoi, no external dependencies.

Also less need on any scripts to set things up, due to chezmoi being more "deterministic" which means applying everything was a lot faster too.

mixmastamyk · a year ago
If you want to avoid force:

    git config --local status.showUntrackedFiles no

dansalias · a year ago
(OP) appreciate all the feedback. I tried stow and chezmoi, neither felt right to me. Evidently that puts me in a small minority!

On the off chance there's anyone else who sees this as worth exploring here's a <1min demo video - https://www.reddit.com/r/unixporn/comments/1f9u1xk/oc_better...

000ooo000 · a year ago
Some responders here almost seem offended you wouldn't use chezmoi. Kind of strange. I couldn't care less about someone using chezmoi/tool x - big deal - but I'm always interested to read how people approach automation of their workflows, the tradeoffs, any cool tricks they employed that I might not have heard of before. Are engineers discouraged from problem solving now? It's not like youre doing this on company time; you are allowed to do things for fun/interest's sake..
josephd79 · a year ago
ok_dad · a year ago
Same! Nothing better than git to store a bunch of text files!
twp · a year ago
How do you handle differences between machines? How do you handle secrets? How do you run scripts?