summaryrefslogtreecommitdiff
path: root/content/guide/clean_your_home.md
blob: ec802a0dfa25065351802e9f70c5c3a6d9390385 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
title: Clean your $HOME
date: 2025-10-30T08:49:28+01:00
index: false
draft: true
#icon: ''
#copied: ["me", "/"]
table: true
---

## XDG Base Directory

### Introduction

The [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir/latest/) (let's abbreviate it to XDG-BDS to be short) defines base directories.

For example, you noticed that Neovim clones the plugin in `$XDG_DATA_HOME` which translates by default to `$HOME/.local/share/`. Thanks to this specification, there is a convention for apps to use specific folders to store or look for data. Neovim (and Helix, and your terminal emulator and so on) use `$XDG_CONFIG_HOME` to look for your configuration files.

### The problem

There is tons of app who doesn't use the XDG BDS and so they kind of pick the place they like to put the cache of their app, or the userdata. And this is annoying. It's funny how the more time goes by the more dotfiles there is in your `$HOME`.

For example, if you use a firefox based browser your have `.mozilla`, you use adb ? `.android`, all your shell's config files like `.zshrc` are in your `$HOME` too.

Look at your `$HOME` :

```sh
ls -a ~/
```

Doesn't it look messy ? Pipe it into word count :

```sh
ls -a ~/ | wc -l
```

I have 31 files in my `$HOME`. And I clean it regularly.

But hopefully, there's some kind of fix for that.

## xdg-ninja

[xdg-ninja](https://github.com/b3nj5m1n/xdg-ninja) is a shell script that checks if the files in your home directory support XDG BDS

Running the command gives you a list of files that have XDG compliance, you have instructions about **how to** move them. If a file doesn't support XDG compliance, `xdg-ninja` returns a link to the issue being discussed.

### Installation

Of course, on Arch-based distros it's really easy :

```sh
paru -S xdg-ninja
sudo pacman -S glow # optional (for pretty printing)
```

And if you don't have an AUR helper, just clone the repo :

```sh
git clone https://github.com/b3nj5m1n/xdg-ninja
```

You can then use the `xdg-ninja.sh` script in the folder.

Check their `README` for more download instructions.

### Usage

I am just going to use it, and tell you what they ask me to do.

So just run the shell script, and the first things **I get** are warnings about variables I didn't set in my shell's config file. So let's add them :

```sh
export XDG_CONFIG_HOME=$HOME/.config
export XDG_DATA_HOME=$HOME/.local/share
export XDG_STATE_HOME=$HOME/.local/state
export XDG_CACHE_HOME=$HOME/.cache
```

And now for each file they talk about I have to follow the instruction.

For example they tell me that the `$HOME/.gitconfig` can be moved in `~/.config/git/config`

### Post cleaning

Now I have 20 folders in my home directory, that's better.

## Links

- [List of programs supporting (or not) XDG BDS](https://wiki.archlinux.org/title/XDG_Base_Directory)
- [Luke Smith video](https://www.youtube.com/watch?v=yy8RoDSdhIQ)