[HN Gopher] Dotfiles: Unofficial Guide to Dotfiles on GitHub
       ___________________________________________________________________
        
       Dotfiles: Unofficial Guide to Dotfiles on GitHub
        
       Author : stefankuehnel
       Score  : 178 points
       Date   : 2024-05-07 10:58 UTC (12 hours ago)
        
 (HTM) web link (dotfiles.github.io)
 (TXT) w3m dump (dotfiles.github.io)
        
       | Frictus wrote:
       | What I see is a mishmash of information.
        
         | hammyhavoc wrote:
         | Is there a better resource you can recommend?
        
       | asicsp wrote:
       | Previous discussion:
       | https://news.ycombinator.com/item?id=32632533 _(256 points | Aug
       | 28, 2022 | 61 comments)_
        
       | kjuulh wrote:
       | This site seems much more like an some of the awesome-<insert
       | tech here> repositories on github than a guide. Although it does
       | give some extra information on the packages.
       | 
       | To not make it took negative. I personally use Chezmoi, which
       | I've been super happy with. The ability to maintain files in a
       | central repository and then pull them into the file system on an
       | update is quite nice.
       | 
       | You can handle merge conflicts and whatnot between your local
       | copy and the upstream dot files. You can opt your files into
       | using go templates in your files which is useful when I need to
       | maintain differences in configs between mac and linux, or in
       | general for just storing secrets out of your dotfiles.
       | 
       | There are some small annoyances but overall it is the only
       | dotfile manager, I've managed to stick with.
        
         | DylanSp wrote:
         | Seconding Chezmoi, it's what I use, and it works well.
        
           | frantathefranta wrote:
           | Third here, it's the easiest tool to setup dotfiles that work
           | on machines ranging from RHEL7 to latest MacOS. Haven't dealt
           | with Windows dotfiles though.
        
             | tedmiston wrote:
             | Fourthing Chezmoi. I tried so many dotfiles tools and it's
             | the only one that does just enough, gets out of my way, and
             | "just works".
             | 
             | Being able to run `chezmoi diff` and `chezmoi apply` are
             | game changers.
        
       | josephd79 wrote:
       | just setup a bare repo and call it a day.
       | 
       | https://www.atlassian.com/git/tutorials/dotfiles
       | 
       | original thread on HN:
       | https://news.ycombinator.com/item?id=11070797
        
         | kryptn wrote:
         | This is how I manage my dotfiles, and it has worked pretty well
         | for me.
        
           | twp wrote:
           | How do you handle differences between machines (e.g. between
           | Linux and macOS)? How do you handle secrets?
        
       | diego898 wrote:
       | Gnu stow has finally been updated to fix a long standing issue so
       | I can once again wholeheartedly recommend it again! It's
       | lightweight and uses symlinks. Last I checked, chezmoi has a
       | symlink mode but it's a bit worse.
        
         | jmondi wrote:
         | Curious what the issue you were running into was? I've been
         | using stow for my dotfiles for at least 8 years now and have
         | been loving it the whole time.
        
           | diego898 wrote:
           | Sorry - should have been specific in top-level comment. I was
           | referring to this one:
           | https://github.com/aspiers/stow/issues/33
           | 
           | Basically, the --dotfiles option was not working with
           | directories so you had to have things that look like this:
           | lazygit/.config/lazygit and now it looks like: lazygit/dot-
           | config/lazygit.
           | 
           | Really a small issue that bugged me forever - shouldn't have
           | made it seem like it was core a problem with stow!
        
         | biftek wrote:
         | What's the issue? I've been using stow for a decade now and
         | can't recall ever running into problems
        
           | diego898 wrote:
           | Sorry - should have been specific in top-level comment (cant
           | edit now). I was referring to this one:
           | https://github.com/aspiers/stow/issues/33
           | 
           | Basically, the --dotfiles option was not working with
           | directories so you had to have things that look like this:
           | lazygit/.config/lazygit and now it looks like: lazygit/dot-
           | config/lazygit.
           | 
           | Really a small issue that bugged me forever - shouldn't have
           | made it seem like it was core a problem with stow!
        
         | fforflo wrote:
         | I guess you're referring to this ?
         | https://github.com/aspiers/stow/issues/65
        
           | diego898 wrote:
           | Sorry - should have been specific in top-level comment. This
           | one: https://github.com/aspiers/stow/issues/33
        
       | theshrike79 wrote:
       | I've been bikeshedding with dotfiles for 20 years and ended up
       | with Chezmoi[0] in the end.
       | 
       | It came down to the fact that it's easy to install and easy to
       | bootstrap as long as your dotfiles are in a public Github repo.
       | It also integrates with a bunch of password managers to grab any
       | secrets you might need in addition.
       | 
       | I use the "run_onchange_install-packages.sh.tmpl" to install
       | basic packages to computers I bootstrap chezmoi on, it adapts
       | based on the operating system using chezmoi's templating
       | system[1]
       | 
       | It takes a few tries to remember the flow of "chezmoi add"ing a
       | file after editing it so that you can push it to Github. After
       | that it's just a matter of chezmoi update on your other computers
       | to bring them up to date.
       | 
       | For .gitconfig I use a .gitconfig.local file on my work computer
       | to override my personal credentials and not have to mess with
       | templating the file.
       | 
       | [0] https://www.chezmoi.io [1] https://www.chezmoi.io/user-
       | guide/advanced/install-packages-...
        
       | gbrindisi wrote:
       | the ultimate bikeshedding with dotfiles is home-manager with nix,
       | an infinite cacophony of deep pain and enlightened pleasure
        
         | yoyohello13 wrote:
         | Yes, I've gone through every style of dotfile management. Stow,
         | bare git repo, custom script, and now nix with home-manager.
         | Using Nix is definitely the best solution so far, largely
         | because not only does it manage the configurations, but also
         | installs the programs you need.
        
           | rgoulter wrote:
           | Plus, Nix allows for installing the same versions of those
           | programs everywhere you're using Nix.
        
         | yjftsjthsd-h wrote:
         | The one thing that makes me hesitate with nix is that it only
         | really supports Linux and Darwin; of the BSDs only FreeBSD has
         | any support (somewhat suboptimal still), and AIUI Windows is
         | also unsupported.
        
       | pprotas wrote:
       | All you need is a symlink script that symlinks files in ~ to
       | ~/path/to/your/dotfiles
       | 
       | https://github.com/pprotas/dotfiles/blob/main/symlink.sh
       | 
       | That's it.
        
         | PurpleRamen wrote:
         | This will not handle cases other targets than $HOME. The
         | automatic deletion seems also very risky. In my own script, I
         | move all pre-existing targets to a separate directory, so I can
         | check later.
        
           | pprotas wrote:
           | You can set the source and target directories to whatever
           | you'd like, this is just what I need for my own use. The
           | automatic deletion is for directories, to prevent recursive
           | symlinks. Of course, you can program your own however you
           | wish, maybe add a confirmation step before removing and/or
           | create a backup beforehand.
        
         | jmondi wrote:
         | Using the GNU stow utility makes this super easy. It even has a
         | --dotfiles flag so you can author your dotfiles as dot-zshrc
         | and when the utility symlinks it, it will be .zshrc. Makes it
         | nice so your source files are not hidden but the actual
         | dotfiles are (as expected).
        
           | pprotas wrote:
           | Although GNU stow is very interesting, I like this simple
           | script because it has no external dependencies. Stow is not
           | available on macos by default, for example.
        
             | kdtsh wrote:
             | It is available though in every package manager for macOS
             | except the App Store, and any user of a script like this on
             | macOS is probably also using Homebrew, macports, Nix, or
             | srcpkg.
        
         | biftek wrote:
         | I use stow, which has some nice advantages vs managing symlinks
         | yourself
         | 
         | https://brandon.invergo.net/news/2012-05-26-using-gnu-stow-t...
        
         | amarshall wrote:
         | Sure, maybe. Though eventually one may find lots of edge cases.
         | What about files in the root that get deleted? What about
         | programs that put wanted state within config dirs? What about
         | programs that ignore symlinked files? What about when you're
         | hacking on your dotfiles and break everything because the
         | active config is the config being edited? What about when you
         | need to vary based on system? What about...
         | 
         | I mean, yea, if it works for you, great! But all of the above
         | are problems I did have. I grew a custom install script for
         | years. Now I use Home Manager and the impermanence module.
        
           | tedmiston wrote:
           | Similar experience here, like: What about when your editor is
           | set to auto save when unfocusing a tab or window and saves
           | while you were mid-edit on your dotfiles and now every new
           | shell is crashing? etc etc
        
           | pprotas wrote:
           | My approach to coding is to tackle these types of problems
           | once they occur, instead of thinking "What about...", "What
           | if...". I don't have these problems you're describing, so the
           | script works great.
        
         | fock wrote:
         | I made it Python, added a simple json-config and mustache-
         | templating. Very portable (where symlinks are), very flexible
         | (also used it for termux for a bit) and very simple.
        
         | vbezhenar wrote:
         | Yeah, same: https://github.com/vbezhenar/dotfiles/blob/main/ln-
         | all
         | 
         | No need for those complex software, just shell script is enough
         | for me.
        
         | tedmiston wrote:
         | I'm sorry, but running `rm -rf ...` in a script against $HOME
         | is a bit too reckless for me.
         | 
         | Maybe you haven't lost data from this yet, but this is where
         | Chezmoi has nice guardrails and protects against, e.g.,
         | modifications or additions accidentally being made to $HOME
         | instead of the dotfiles dir, which look like they would be
         | silently blown out by your current process.
         | 
         | Just my 2C/ from someone who used to do it this way and lost
         | data because of it.
        
           | pprotas wrote:
           | What do you think is the risk here? I don't see a code path
           | to remove my home dir in the script
           | 
           | EDIT: Unless I have a dir called "*" in my dotfiles, but at
           | that point I deserve to have my home dir removed :P ZSH also
           | asks for confirmation first
        
         | matheusmoreira wrote:
         | I think I'm the only person insane enough to use a makefile for
         | this.
         | 
         | https://github.com/matheusmoreira/.files/blob/master/GNUmake...
         | 
         | https://www.matheusmoreira.com/articles/managing-dotfiles-wi...
         | 
         | It even supports the XDG stuff as well as variables like
         | GNUPGHOME.
        
       | travis51 wrote:
       | I highly recommend dotter, especially if your dotfiles have
       | variation from machine to machine and or if you don't need all of
       | them at a given time. It's pretty simple and lightweight
       | 
       | https://github.com/SuperCuber/dotter
        
       | throwaway918274 wrote:
       | 1. sudo apt/dnf/zypper install stow
       | 
       | 2. man stow
       | 
       | 3. git init ~/dotfiles
       | 
       | have at'er
        
       | low_key wrote:
       | I started managing my dotfiles in git and followed the pattern I
       | found in Anders Knudsen's repository below. The most painful
       | thing has been coming up with config that works across Linux and
       | MacOS, but that's been chosen pain that can easily be avoided.
       | 
       | https://github.com/andersix/dotfiles
        
         | hk1337 wrote:
         | I have been keeping them in separate branches because I have
         | had macOS with intel and arm because there were differences in
         | the config.
        
         | josephd79 wrote:
         | yup, a bare repo. its the easiest way I think.
        
         | asix66 wrote:
         | This method, using a bare git repo, is really an elegant,
         | efficient, and easy way to manage one's dotfiles.
         | 
         | In the end, how you do it is personal pref. I liken it to
         | editor wars, vim vs emacs, etc. What works for me, may not work
         | for you.
         | 
         | PS: these are my dotfiles (link is my repo), and I've used this
         | method for some 5 plus yrs now and it works well for me. I
         | really like how easy it is to spool up a new linux instance and
         | have my config ready to go in mere seconds.
         | 
         | I've not used branches yet, for different OS'en, so my zshrc
         | and bashrc have conditional checks for OS. I will be looking at
         | using branches in the future since it does sound like it would
         | make shell rc files cleaner.
        
       | tionis wrote:
       | I'm currently using a git based approach for my dotfiles, similar
       | to the one notes here[1]. I've got one significant change,
       | though: All my dotfile management works over my cfg[2] script
       | that helps me maintain a main branch for dotfiles for all
       | machines and then branches that branch off of that main like
       | 'main.arch.MACHINE_NAME' that are merged like a waterfall during
       | sync (main -[merge]-> main.arch -[merge]->
       | main.arch.MACHINE_NAME). (I can also cherry pick up the
       | waterfall)
       | 
       | [1]: https://www.atlassian.com/git/tutorials/dotfiles [2]:
       | https://gist.github.com/tionis/a0f23a7a33b0e289f1b03cc6ff503...
        
       | keybored wrote:
       | Symlinks and Git. A remote like GitHub is then a minor bonus.
       | 
       | I didn't store my dotfiles on GitHub because they didn't used to
       | have free private repositories. (Why would I share my dotfiles?)
        
       | bbor wrote:
       | The good stuff: https://dotfiles.github.io/inspiration/
        
       | nirvdrum wrote:
       | I've had really good luck with vcsh and git-crypt. vcsh can be a
       | little awkward to use because git commands need to be scoped to
       | the vcsh project, but you get used to it. I like having separate
       | git repos for separate roles (e.g., fish-common, fish-personal,
       | fish-work). Then, depending on what I'm doing on a particular
       | machine I can pull in just the roles I need. It may seem like
       | overkill, but I've found it very helpful in sharing my dev config
       | without pulling personal stuff onto a work machine, vice versa.
       | 
       | git-crypt allows me to protect sensitive files while still
       | tracking them in a git repo. I don't think I'd rely on it for
       | shared projects, but it works well for me.
        
       | botanical wrote:
       | I'm using yadm for some years now, which works really well:
       | 
       | https://github.com/TheLocehiliosan/yadm
        
         | JimDabell wrote:
         | I've tried a bunch of these out and settled on yadm as well.
         | It's basically a shim for Git that tracks your home directory
         | with a bare repo stored elsewhere.
        
       | mehdix wrote:
       | Just use your home folder as a git repo, rename .git, create
       | alias "githome" to git cli pointing to that directory and viola,
       | you have all you need.
        
       | LorenzoGood wrote:
       | For me, I have found nix home manager to be the most effective
       | solution for managing my dotfiles.
       | 
       | The migration process was easy, and I was able to use it to
       | replace my sim link script with it's file directives.
       | 
       | It also integrates well with my Nixos Systems.
        
         | ar_lan wrote:
         | Nix + Home Manager is by far the easiest-to-manage system for
         | dotfile management to date for me.
         | 
         | The added bonus is:
         | 
         | 1. No need for complicated directory structures that a symlink-
         | like script needs to manage.
         | 
         | 2. Dotfile management coupled with package management. Dotfiles
         | only make sense as configuration to packages you have - why
         | would you not tie these together?
         | 
         | 3. Minor-to-no tweaks required to have a fully reproduced setup
         | on any machine.
         | 
         | Seriously, I transitioned my dotfiles from my NixOS machine at
         | home to my work-issued M2 within... an hour?
         | 
         | I will never not evangelize Nix.
        
         | Cu3PO42 wrote:
         | I have also ended up with Home-Manager. It's an extremely
         | powerful tool that I am unlikely to replace in the next ten or
         | so years, but you also need to learn a whole programming
         | language (Nix) plus a DSL (the NixOS module system) to get the
         | most out of it.
         | 
         | On the upside: you do get a whole purpose-build language for
         | configuring your system, piecing together your configurations
         | dynamically, installing your packages and so much more.
         | 
         | Ability to install packages is another huge thing. Home-Manager
         | does not just configure my tools, it also installs them
         | (including my DE), so I can get started with my custom config
         | on a new system in a matter of minutes.
        
       | epiccoleman wrote:
       | This one's my favorite - has been working reliably and with
       | barely any intervention for years now:
       | https://github.com/andsens/homeshick
       | 
       | My own dotfiles: https://github.com/epiccoleman/dotfiles
        
       | sevagh wrote:
       | Am I missing something or is the use of "GitHub" weird here? Are
       | they GitHub employees? None of the creators seem associated with
       | GitHub. They're _users_ of GitHub, nothing more.
        
       ___________________________________________________________________
       (page generated 2024-05-07 23:01 UTC)