I'm wondering if I can do something like:

export HOME=$HOME:$HOME/.configs

So that I can keep all my custom configs in ~/.configs.

I know it's possible to set it but I'm not sure if it will cause problems down the road. Is this safe? Is there a more standard way?

  • 3
    Environment application are interpreted by applications (i.e. by shell bash), and neither of them (probably) supports this. Anyway, this sounds like an XY problem. What are you trying to achieve with that? – myaut Jan 16 '17 at 20:49
  • 1
    Yeah, I'd like to know about the Y problem too. All your config files are already in the right place, where programs expect to find them. What do you intend to do? – xhienne Jan 16 '17 at 21:10

Firstly, albeit possible, and experts might need this in certain rare cases, you shouldn't change the value of the HOME environment variable, it is set by your system.

Secondly, the content of HOME is expected to be one, and only one, (existing) directory: your home directory.

See what POSIX says about HOME:

HOME: The system shall initialize this variable at the time of login to be a pathname of the user's home directory.

| improve this answer | |

The $HOME/.config directory is part of the XDG Specification and is determined by the value of $XDG_CONFIG_HOME.

Theoretically, this means that if you want your configuration files stored somewhere else you just need to set $XDG_CONFIG_HOME to that preferred location.

In practice, however, you may well find instances of software that blindly writes to $HOME/.config/... rather than following the XDG Specification. Particularly as it's not a required part of any distribution.

For applications that do follow XDG, you can also have a set of directories ($XDG_CONFIG_DIRS colon separated, like $PATH) that define other locations from which default values should be sourced. The default value for this should be /etc/xdg.

Now, the next question that should be on your lips is, "OK, so where do I set $XDG_CONFIG_HOME?" and unfortunately this gets rather complicated.

The summary seems to be that you will probably get away with putting it in .profile (or .bash_profile, .bashrc), but that a global configuration via PAM might be required. Personally I've not tried this, and in particular I don't see how a .profile based solution could work with a GUI-based login environment.

The second question might then be "How do I move my configuration to this new location?", which is also fraught with potential issues. Sigh.

The easiest option here is probably to use a symbolic link that points $HOME/.config to your preferred location. This handles not only any issues with setting $XDG_CONFIG_DIR but also any issues with applications that insist on looking directly under $HOME/.config.

test -d .config && mv .config .config_old
ln -s /path/to/preferred_config_dir .config
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.