+++
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][1] in a git repository on codeberg.org and I
created the repository like:
[1]: https://www.thegeekyway.com/what-are-dotfiles/
First of all, create an empty directory in your home directory -- I prefer
a hidden one, so I'll go for `.cfg` for now.
```console
$ 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:
```zsh
__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:
```fish
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:
```console
$ aconf config --local status.showUntrackedFiles no
```
If you want these files shown again, set it to `normal`.
![manpage excerpt](git-config.png "You can set it to one of `no`, `normal` and `all`.")