Dotfiles Administration – mitxela.com
Progress: Full
Not a lot of a challenge, however this is likely to be helpful for some people. This is how I’m at present preserving observe of all of the configuration for my laptop computer.
The system I’ve settled on is copied from different folks – monitoring dotfiles as a git repo – however taken to its excessive the place your entire root filesystem is trackable. Importantly,
- Any file on the machine may be added to the dotfiles repo
- The dotfiles repo does not intrude with another git repos you are working with
Beginning with the fundamentals, the repo must reside someplace, so we initialise a naked git repo in ~/.dotfiles
. I named the default department the identical as this laptop computer’s hostname (magma) with the obscure concept that a number of machines can share the dotfiles repo with totally different branches. It might make sense to have a template department, with many of the generic settings (like vimrc), and particular branches with machine-specific config, however meaning lots of merging between branches, which you’ll or could not have the persistence for.
We make an alias:
alias dotfiles='git --git-dir=/house/mx/.dotfiles --work-tree=/'
Now typing dotfiles standing
or dotfiles log
will present the standing or log of the repo, no matter in the event you’re at present in one other repo. In fact trying on the standing will most likely take without end because the work tree is /, so it should listing each single file on the filesystem as untracked. There are just a few methods to cease this, however I went with merely telling git to not present untracked recordsdata:
dotfiles config --local standing.showUntrackedFiles no
The recordsdata should not ignored, you’ll be able to simply add them usually, however till then they will not be listed. That is 90% of the work carried out, now you can add some recordsdata, both native, in your house listing, or anyplace on the system, and commit them to the repo.
dotfiles add ~/.bashrc dotfiles add /and many others/udev/guidelines.d/70-ftdi.guidelines dotfiles commit
All nicely and good. However I shortly discovered myself craving extra so I expanded on this with just a few extra options. First, I wholly depend upon tig for shortly seeing the state or historical past of a git repo, so to invoke tig on the dotfiles repo we use this:
alias dtig='GIT_DIR=/house/mx/.dotfiles GIT_WORK_TREE=/ tig'
Second, due to the large unfold of the place recordsdata are, I discovered myself all the time needing to listing which recordsdata are explicitly tracked, utilizing dotfiles ls-files
. It is actually useful to have the ability to shortly see the place that config file was that you’ll want to edit once more. I went a bit overboard right here and added a bash operate to show a abstract.
dot() sed "s#$i##")" echo -e "¬/$i¬e[0;33m$(dotfiles -c shade.ui=all the time log -1 --format="%s" -- $i)e[0m" carried out )
If referred to as with arguments, it simply invokes dotfiles
, so I can do dot standing
or no matter. In any other case, it exhibits me a flowery abstract that appears like this:
The primary column exhibits the standing flags in color (modified, deleted, staged, and many others). On this screenshot, firefox userChrome has been modified, and bashrc has a modification staged. The second column is the complete path to the file. The third column is the commit message for the final change affecting that file, a bit just like the abstract github or gitlab may present.
This setup is immensely satisfying. In the identical means that git allows you to muck about with recordsdata with out worrying about getting again to a working state, I can now muck about with something on the OS. The variety of occasions prior to now that I’ve had an issue, discovered it and stuck it, solely to re-encounter it just a few years later and need to work it out once more, nicely, all of the sudden all of it appears price it, as I can now admire having a whole historical past of each config file I care about.
Probably the most frequent issues I encounter, particularly on the Home windows machine, is that there is a resolution to some downside that little doubt requires enhancing the registry, which I can do, however then just a few weeks later some software program replace reverts the repair. I used to have a notepad with all of the adjustments I might made to the registry in order that I can re-apply them once they get overwritten. It was an terrible, unsatisfying mess. The identical factor can occur on linux, however no less than now I can instantly see the consequences by operating my dot
operate above. If a tracked file is modified after a system replace, I can see it, and both restore it or cope with the issue another means, however no less than it does not sit there silently till I ultimately run into the issue once more.
I began this some time again, however my present laptop computer is the primary time I’ve tracked every thing from a clear set up. There’s all the time a little bit of hacking to get the boot course of good and to iron out the {hardware} quirks, and having that saved within the dotfiles historical past means subsequent time, in just a few years, I will have one thing concrete to look again on, as a substitute of poking round within the depths of the outdated /and many others/
.
We may go additional with this. I thought of splitting the repo into two, both as two .dotfiles
folders or as two branches with a git-worktree association. One can be a shared department with every thing I all the time need, shell config, vimrc and so forth. The opposite would have the machine-specific config, keycode remaps, udev guidelines and so forth. This might be a really clear resolution if I wished to have every thing tracked throughout a number of machines. I’ve a sense there’d be some niggling edge case that might journey it up, nonetheless, the place one thing tracked within the shared department conflicts with one thing you need to domestically be totally different. It may fairly shortly flip into a multitude.
Anyway, that is my dotfiles monitoring recommendation, there could also be higher methods to do it however in the event you use linux and do not have something like this already, I strongly suggest it.
Questions? Feedback? Take a look at the Forum