anishathalye / dotbot

A tool that bootstraps your dotfiles ⚡️
MIT License
7.04k stars 291 forks source link

Inclusion list #335

Closed musjj closed 1 year ago

musjj commented 1 year ago

It would be useful to have an inclusion list to choose which files gets linked inside a folder.

This is useful for programs that puts cache and other files alongside the user's config.

In programs like mpv, every new scripts we install can potentially add additional cache files to our config, so tracking them with a .gitignore is kind of annoying.

With an special syntax for includes, we can reduce something like:

~/.config/mpv/mpv.conf: mpv/mpv.conf
~/.config/mpv/input.conf: mpv/input.conf
~/.config/mpv/scripts: mpv/scripts
~/.config/mpv/script-opts: mpv/script-opts

into:

~/.config/mpv:
  path: mpv
  include:
    - mpv.conf
    - input.conf
    - scripts
    - script-opts
JCallicoat commented 1 year ago

You should not include cache files in your git repo regardless of dotbot. You can use negation in .gitignore like this (ignore everything except those files and dirs):

*
!mpv.conf
!input.conf
!scripts
!scripts/**
!scripts-opts
!scripts-opts/**
musjj commented 1 year ago

I wasn't purposely including cache files in my dotfiles. It's just what happens when you link the folder directly (~/.config/mpv: mpv). But I figured out a simpler way to do this:

~/.config/mpv:
  path: mpv/*
  glob: true

This way only the files inside my mpv dotfiles gets linked, and not the other way around.