If I look at my home directory there are a large number of dot files. If I am creating a new program that needs a user configuration file, is there any guidance where to put it? I could imagine creating a new dot directory ~/.myProgramName or maybe I should add it to /.config or ~/.local.
- 807,993
- 194
- 1,674
- 2,175
- 5,151
- 9
- 47
- 73
1 Answers
The .config directory is a newish development courtesy of XDG that seems, deservedly, to have won favour.
Personally, I don't mind a dot directory of your own. A bunch of separate dot files (ala bash and various old school tools) in the toplevel of $HOME is a bit silly. Choosing a single dot file is a bad idea, because if in the future you realize maybe there are a couple more files that would be good to have, you have a possible backward compatibility issue, etc. So don't bother starting out that way. Use a directory, even if you are only going to have one file in it.
A better place for that directory is still in ~/.config, unless you are very lazy, because of course you must first check to make sure it actually exists and create it if necessary (which is fine). Note you don't need a dot prefix if your directory is in the .config directory.
So to summarize:
- use a directory, not a standalone file
- put that directory in
$HOME/.config
- 86,451
- 30
- 200
- 258