2.5 KiB
+++ title = 'Publishing dotfiles' aliases = '/posts/2023-11-02-publishing-dotfiles' summary = '''Another quick'n'dirty post about how I published my dotfiles.''' date = '2023-11-02T19:52:37+0100' #lastmod = '' categories = [ 'computerstuff' ] tags = [ 'git' ]
+++
I've saved my main configuration files since years either on my NAS or on a git repository off site somewhere on the internet. I used Github for this (as many others did) but I started my own instance of Gitea when I created my own Mastodon instance at the end of 2022. I closed down both of them, my git repos moved over to Codeberg and because I used Cloudflare before I actually wanted to use Codeberg pages in the first place, but I went the rsync way. I now have a pre-push hook in my git repository of my website that rsyncs my hugo made website to my webserver... But we should stay on topic here...
tl;dr I do have my dotfiles in a git repository on codeberg.org and I created the repository like:
First of all, create an empty directory in your home directory -- I prefer
a hidden one, so I'll go for .cfg
for now.
$ git init --bare $HOME/.cfg
An alias around git with specific worktree and git directory comes in handy at this moment. You can also create a function, this is totally up to you.
I got a function in my zsh configuration and an alias in my fish configuration.
In my .zaliases
file there is something like this:
__is_available git && [[ -d ~/.cfg ]] \
&& function aconf {
git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
__is_available
is another function that checks if a program is installed.
My fish configuration looks like this:
if type -q git; and test -d ~/.cfg
# function aconf --description "Add files to dotfiles repo"
alias aconf="git --git-dir=$HOME/.cfg/ --work-tree=$HOME $argv"
# end
end
Note, I had this as a function before (hence the comments (#)), but I wanted to try this as an alias only at the moment. I won't update this post if I may change this back again.
Running aconf status
in $HOME
would print a huge list of files, we don't want
that (well, I do sometimes switch it on again to have a look at
files or dirs that I may have missed to add) and we can ignore these untracked files with:
$ aconf config --local status.showUntrackedFiles no
If you want these files shown again, set it to normal
.