How do you sync your dotfiles?

Hi,

I am actually making more use of personal dotfiles. As I am also discovering cooler cli applications, like ranger, termite, etc… , my list of config and shortcuts and bash aliasses is growing very much.

I now have 4 pcs… And for example I work on pc1 in the morning, the other day an pc2, and on pc4 in the evening, etc…

And I am changing my config very constantly. Until now I did “sync” my dotfiles manually, but I found out that I am missing a lot and I dont know where I had made which change… etc… you see the problem.

I am pretty sure you have a better solution to tell me about… kind of…: how would you sync your dotfiles if so…
I though of course of things like “ln” and using nextcloud… but… it seems as this could have the “potential” to break something :crazy_face:
Dont know…

Any ideas?

Thanks and kind regards

I use git to manage most files I want on multiple systems.
(not just dot files but also my password manager data. The gnupg keys to unlock those however I keep on a usb stick, with a back-up copy and hard-copy stored in a fire resistant storage)

1 Like

Hi,

Mhm… I never used git (but know what its main purpose is…).
Am I right, that I then would have to pull it up whenever I have made a change to a file? But then also manually push it down on the 3 other pcs?

You would need to push chages (I push all changes to a git repo on my vps) and pull from computers with older versions.
You could probably automate the pulling on a push, but I don’t bother.

1 Like

well I have a fully synced work PC with my home-work PC, both use Fedora Workstation. I connect my home-work PC to the corporate LAN via wireguard over OpenWRT router and use git+bash+python.
sync is done hourly and when I log out from my work PC full sync check is done (same at night when I log out from my home work PC, full sync check is done), but I know how to code so for me it is easy.
I use GIT since I like to file versioning, I keep daily version of files for the last month and weekly for the past year, it takes a lot of space but with latex comments I can easily find any old or new config I need.

probably user based version that doesn’t require coding is using backup tool like dejadup with autobackup, some tool for file sync (google drive, dropbox) and cron job to auto extract backup and rewrite files, for file system backup timeshift (100% I don’t recommend using timeshift in /home).

Regards, Alex

Perfectly stated.

If you need the files on multiple computers to be the same…I can’t think of a better way that git versioning.

2 Likes

Both of the systems that I’m recommending use git, but I will admit that I still need to decide on one of them and use it myself.

The above is used by Wimpy the developer of Ubuntu Mate and the lead developer for Ubuntu Desktop. I would imagine that if it is good enough for him then it would be a good tool for just about anyone.

The above article was written by a DLN community member about chezmoi. Perhaps @rwaltr could chime in on this thread and give you more information.

I seriously need to replace my current method which involves trying to remember to copy my changed dotfiles into a folder that I sync between all of my machines using Syncthing. I have 4 computers that I use regularly and it would be nice to have my dotfiles backed up between them. Of course, I don’t make it easy because Box#1 is Fedora 32, Box#2 is Ubuntu Mate 20.04, Box#3 is MX Linux, and Box#4 is Win10 running WSL with Ubuntu. Just keeping my .vimrc synced up between them all would be nice. :wink:

2 Likes

I second chezmoi. It (along with git) is what I currently use using just a single machine. Take a look at the project’s how to which shows how to use it to manage dotfiles across multiple machines first thing on the page. It could be a good solution in your use case.

Personally, after using chezmoi for a while, I’m planning on working on a custom solution and taking inspiration from its design, despite it being the best tool to manage dotfiles for me, because I came across some edge cases with my workflow that it doesn’t have a solution for.

1 Like

What was some of these edge cases?

Chezmoi is much more than a dotfile manager,.it’s basically a templating engine

It’s not a big deal really but more of a “It hurts my OCD.” kind of thing lol. I use emacs as my editor and because chezmoi edit prompts edits in .local/share/chezmoi, emacs acts kinda weird. The thing that bugs me the most is its linter’s behavior when editing emacs “.el” configs. These “quirks” prompted me to think of rolling out a custom solution inspired by chezmoi, where I edit my dotfiles in place and sync them into a folder and commit that into git.

Pagure by Fedora is a Version Control (same as github, gitlab, bitbucket) based on Git.
probably the best advantage is that you can easily make your own private pagure git and host it on your own server (Gitlab offers similar, but the advantage here is that it can work with IP in LAN only mode).
My company has been using it for years since it stared downtime is zero for now, I home I use git.

https://pagure.io/

Regards, Alex

1 Like

Intresting, Thank you for sharing

As others have already said, thanks for sharing this.

In my “Linux life”, I am approaching the point where I need this. Your timing couldn’t have been better.

1 Like

I just watched that Fedora Classroom when it went live. I’m not a programmer, and I’m still trying to wrap my head around the terminology and workflow of git. This one was pretty good.

Another self hosted git that that I can recommend is Gitea. My son loves to program and he installed it on our Debian Freedombox server in our home and gave me an account too. I will say that it has one of the nicest web ui’s that I have seen for a self-hosted program, and it has so many of the features that you see in Github or Gitlab.

1 Like

yeah it is cool a friend of mine uses gitea,I am personally more of a pure git (but I am a coder and former sys admin) I want to make all apps I need my self, custom scripts etc, even made a clone of a popular messaging app with custom encryption just to make my GF feel special and so she can be sure our talks are always private. engineering mind set is if it doesn’t exit make it exits or do it your self.

I use Fedora for about 10 years, Red Hat Academy and Fedora Classroom is really great to follow it is made for everyone to be able to follow not just coders and sys admin. The best part about Linux and FOSS/FLOSS is that you get the option to choose your OS, DE and Apps. Any GIT apps is great so my recommendation is use the one that is simplest to you for you, your pc your os / data, your git choice.

as a former university lecturer it s great to read that young people are getting into Linux in 2020.

Regards, Alex

Another good video is from the missing semester!
https://missing.csail.mit.edu/2020/version-control/

1 Like

Thanks for this recommendation, I enjoy the missing semester videos, but I hadn’t gotten to that one yet.

@AstraAdria4Ari, Linux helped my teenage son develop his love of programming. 3 summers ago, I introduced my son to Linux using a 1st gen RPi when he was going into 7th grade. He learned C++, contributed to MX Linux, learned Python, became a vim ninja, learned bash scripting, and dabbles with Rust. I think he will be on Linux for the rest of his life. :slight_smile:

2 Likes

I started looking into Yadm and Chezmoi a little more. Perhaps @rwaltr or @leftybournes you know the answer to this.

It looks like Yadm is basically a way to run git in your home directory and it basically uses all of the git commands. Yadm would work well if you just wanted to keep two computers, especially two that were running the same distro and DE in sync with one another. But it doesn’t appear that you can have unique configurations for each computer that is syncing with your Yadm git repo. I suppose the other advantage of Yadm is that you don’t have to change the workflow you have become used to when editing your dotfiles (using the special Chezmoi commands to edit a file). You just edit them and then run the Yadm git style commands to commit the changed files.

Chezmoi seems to allow unique configurations for each computer even though they are saving them to the same Chezmoi git repo? Perhaps Chezmoi would be better for someone like me who runs more that one distro and different DE and WM on each of them. Does Chezmoi let you keep certain dotfiles across all computers the same, for example I would kind of like my .vimrc to be the same but on one computer I would need my .fluxbox directory, but I wouldn’t need that on my Fedora 32 box or my Ubuntu Mate box. It seems like Yadm would pull down everything to all of the computers that I have it installed on so I would end up with some dotfiles or directories that I wouldn’t even need on some computers.

Am I understanding this correctly?

1 Like

yup. its a wrapper with a few features attached.

Correct. because this is not a problem many people have. The aim is to sync your Dotfiles, not separate them.

Correct, with Yadm, you are editing the files directly.

Yup. Chezmoi is acts more like a template engine. For example.

Your editing your vimrc, but for some reason or another, you have the following

" Better Syntax Support
Plug 'sheerun/vim-polyglot'
" File Explorer
Plug 'scrooloose/NERDTree'
" Auto pairs for '(' '[' '{' 
Plug 'jiangmiao/auto-pairs'
"Chezmoi Integration
Plug 'Lilja/vim-chezmoi'
"Vimwiki
Plug 'vimwiki/vimwiki'
" FZF
Plug 'junegunn/fzf.vim'
" Ansible-vim
Plug 'pearofducks/ansible-vim'
"Truely dank plugz
Plug 'rwaltr/notarealplug'

But man. you REALLY dont want that last plug in on every computer. just your desktop. what you can do is convert that to a template. which adds a .tmpl to the end of the string. and allows you to insert jinja templating

" Better Syntax Support
Plug 'sheerun/vim-polyglot'
" File Explorer
Plug 'scrooloose/NERDTree'
" Auto pairs for '(' '[' '{' 
Plug 'jiangmiao/auto-pairs'
"Chezmoi Integration
Plug 'Lilja/vim-chezmoi'
"Vimwiki
Plug 'vimwiki/vimwiki'
" FZF
Plug 'junegunn/fzf.vim'
" Ansible-vim
Plug 'pearofducks/ansible-vim'
{{- if eq .chezmoi.hostname "MyDesktop" }}
"Truely dank plugz
Plug 'rwaltr/notarealplug'
{{- end }}

This will result in the last section not being present on anything that doesnt have the hostname “My desktop”

The template engine can also manage secrets. Chezmoi will interact with multiple secret managers to apply these configurations.

Lets say you have some env file…

RESTIC_REPO=sftp:restic.example.com
RESTIC_PASSWORD=DANKMEMES

Oh no! We dont want this in plain text… How about we use pass?

RESTIC_REPO=sftp:restic.example.com
RESTIC_PASSWORD={{- pass "resticpass" -}}

This will generate the file with whatever the contents of pass show resticpass are. This allows you to keep your secrets outside of Git… and into a password manager.
You can also GPG encrypt files. Chezmoi will decrypt them when applied.

This is why you cannot edit your dotfiles directly. Because what is on your computer is likely not you base config, but a result from a template being generated. (However Chezmoi-vim helps with that)

2 Likes