Skip to content

Feature Request: add support for global config using $XDG_CONFIG_HOME #2465

@julie777

Description

@julie777

I would like to see support for using the XDG directory specification for config files.
https://specifications.freedesktop.org/basedir/latest/

XDG defines a set of standard environment variables in order to provide known locations for various kinds of files.
Regarding config files, $XDG_CONFIG_HOME (defaulted to ~/.config/) is used to set the default location for a user's config files. XDG_CONFIG_DIRS specifies a search path to use if the config file is not found in XDG_CONFIG_HOME.

The benefits of XDG_CONFIG_HOME aka ~/.config are:

  • is that it reduces file system clutter because the user's home directory is not full of dot files
  • it makes it easy to move configuration files to another machine or back them up
  • it certainly makes it very easy to see what programs have a global configuration
  • it allows the user to choose a different location, such as a shared file system

The configuration for a program may either be a single config file in ~/.config/, in which case it should not be hidden. Example would be moving ~/.isort.cfg to ~/.config/isort.cfg
If the configuration for a program is a directory, such as ~/.vim/ it should be a non-hidden directory in ~/.config such as ~/.config/vim.

Note:
I am not proposing changing looking in the current directory or the project directory first. However, I think looking at 25 parent directories is excessive. If the project directory can be recognized then the search should stop there and jump directly to the global config. The project directory can be recognized by the presence of:

  • a pyproject.toml directory
  • a setup.py directory
  • a .git directory

There might also be other ways, but the above is a quick and simple list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions