Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Christophe Colombier
Christophe Colombier

Posted on • Edited on

     

Clean your home folder ! discover XDG

Today, I would like to talk aboutXDG base directory specification

You can read the article, but the idea is a guidance for people creating and maintaining software programs.

What is all about ?

You should have noticed there are a lot of files starting with. in your home directory. Some are configuration files, some are cache, some are runtime data.

What is the problem ?

Well, it's a mess. Having all these files in your home folder is a bit strange, also not easy to follow if you have a dotfiles strategy.

Before/After effect

Instead of having

~/.gitconfig~/.tmux.conf......
Enter fullscreen modeExit fullscreen mode

you could have

~/.config/git/config~/.config/tmux/tmux.conf...
Enter fullscreen modeExit fullscreen mode

This specification is progressively adopted, you will see a lot of files in ~/.config/ or ~/.cache folders. These two are the most commonly used by the programs.

So right now, a lot of programs started to support XDG base directory specifications, some made the choice to use directly the ~/.config to store config files, some simply argues they don't want to support them 🤦.

You can imaginethe amount of mess

What are the benefits of using XDG

  • it's cleaner
  • you have one folder per program
  • you can add a README.md file in each folder to take notes or to share information when sharing dotfiles on GitHub.

How to start ?

You can do it manually, by reading every program man files... or ... you can use tools that will report you the things you can migrate.

Here are my favorites:

GitHub logo b3nj5m1n / xdg-ninja

A shell script which checks your $HOME for unwanted files and directories.

xdg-ninja

Because you wouldn't let just anyone into your$HOME


A shell script that checks your$HOME for unwanted files and directories.

xdg-ninja command output

Whenxdg-ninja encounters a file or directory it knows about, it will tell you whether it's possible to move it to the appropriate location, and how to do it.

The configurations are from thearch wiki page on XDG_BASE_DIR,antidot (thanks to Scr0nch for writing a conversion tool), and crowdsourced by other users.

Installing

Manual Installation

Clone the repository, then run the./xdg-ninja.sh script.

git clone https://github.com/b3nj5m1n/xdg-ninjacd xdg-ninja./xdg-ninja.sh
Enter fullscreen modeExit fullscreen mode

This will run every test in the default configuration.

Turn onflakes, then run the following command:

nix run github:b3nj5m1n/xdg-ninja
Enter fullscreen modeExit fullscreen mode

Note

Due to howxdg-ninja is developed, releases are not cut, so Homebrew ships a stale version, therefore you have to install and upgradexdg-ninja from the git HEAD. ref:#204

Homebrew will not…

The first one is only about reporting current status about each dotfile. It also reports a status for files that are currently unsupported, or when developers declined to support XDG.

It provides you information on how to migrate them.

This one is very cool, because it will never simply make no change to your dotfiles.

GitHub logo doron-cohen / antidot

Cleans up your $HOME from those pesky dotfiles

antidot 🏠 🔸 💥

Pipeline

Cleans up your$HOME from those pesky dotfiles.

Migration from Pre 0.6.0 Versions

Please backup your environment variable and aliases files (in$XDG_DATA_HOME/antidot/{env,alias}.*). After version 0.6.0 antidot stores env exports and alias definitions in a JSON file and generates from it shell definition files.

Intro

For years I stood by and saw how countless applications populate my home dir with dotfiles.

No more!antidot is a tool to automatically detect and remove dotfiles from$HOME without any risks. It will move files to more appropriate locations (based onXDG base directory specifications). It will also set environment variables, declare aliases and use symlinks to ensure apps can find their files.

Installation

Arch Linux

yay -Sy antidot-bin
Enter fullscreen modeExit fullscreen mode

Homebrew

brew install doron-cohen/tap/antidot
Enter fullscreen modeExit fullscreen mode

Go to thereleases section and grab the one that fits your OS.

After installing runantidot update to download the latest rules file…

This one is about listing them, it reports a bit less results.
But it can help you to migrate them automatically.

Top comments(4)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
muescha profile image
Michael
  • Joined
• Edited on• Edited

here are similar movement with .dotfiles on macOS - I added a link to your article:

github.com/pi0/config-dir/discussi...

CollapseExpand
 
sanixdarker profile image
darker
Backend engineer, Software developer, Electronic Geek, i like create simple tools doing amazing stuffs.
• Edited on• Edited

Thanks for sharing this, didn't know about xdg-ninja !
it's true am handling everything in my ~/.config dir manually except for tmux.conf and gitconfig, am lazy ya know...🙈... but i will definetlly change that !

$ tree -L 1 ~/.config/   ├── alacritty   ├── i3   ├── mpv   ├── neofetch   ├── neomutt   ├── nvim   ├── pypoetry   ├── ranger   ├── rofi   ├── thefuck   ├── wireshark   ├── yarn
Enter fullscreen modeExit fullscreen mode
CollapseExpand
 
efdev profile image
Eric F 🇺🇦
Linux & Mac user. Like scripting, open-source, computers/servers in general, and DIY. Doing some web-dev, and the constant rebuild of my home network.Facebook… No way.
  • Location
    Inbetween Europe (mostly Swe)
  • Joined

👍 Will definitely look it to the.config/git There's also the--system location/etc/gitconfig. Making thingsreally global, and just keep personal stuff/info in the other one.

CollapseExpand
 
ccoveille profile image
Christophe Colombier
Smiling person, father of two, Husband, Senior Developer/Architect (in that exact order, it's important)Experience in development since 2004Linux user and advocate since 2001
  • Location
    Villeurbanne, France
  • Education
    Arts et Métiers
  • Work
    VP Technology
  • Joined

Yes, it's possible to have clean config files and home folder. It's just a pity that's not the default behavior

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Smiling person, father of two, Husband, Senior Developer/Architect (in that exact order, it's important)Experience in development since 2004Linux user and advocate since 2001
  • Location
    Villeurbanne, France
  • Education
    Arts et Métiers
  • Work
    VP Technology
  • Joined

More fromChristophe Colombier

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp