Hub: respect the XDG_CONFIG_HOME environment variable

Created on 7 Dec 2015  路  6Comments  路  Source: github/hub

Thank you for using ~/.config/hub for your configuration file, as opposed to polluting the base home directory with yet another top-level dot file (~/.hub).

It would be even better if this configuration file was relocatable. This is covered by the XDG Base Directory Specification. Basically, this means to check for the environment variable XDG_CONFIG_HOME. If it exists, make your configuration file relative to that (${XDG_CONFIG_HOME}/hub). If it does not exist, make your configuration file relative to ~/.config (matching the existing behavior). Because you are already using the default relative path, it would be a backwards compatible change for existing users.

config feature

Most helpful comment

Also, please store sensitive information (like oauth_token) under $XDG_CACHE_HOME, not $XDG_CONFIG_HOME. The latter location is often published in dotfiles, the former is usually not.

All 6 comments

it would also match git. Git also supports the XDG Base Directory Specification.

Thanks for the suggestion! This is definitely something we could do. Now accepting pull requests :wink:

Also, please store sensitive information (like oauth_token) under $XDG_CACHE_HOME, not $XDG_CONFIG_HOME. The latter location is often published in dotfiles, the former is usually not.

$XDG_CACHE_HOME can disappear at any time though. It'd be best if it stored in the system keyring, but $XDG_DATA_HOME could be used instead.

Agree with @jrobeson -- This should definitely be $XDG_DATA_HOME...

And, further, the canonical way of utilizing those directories is for applications to create a directory for which a config, data, or cache files will then reside in, rather than putting a single file at the base of the XDG directory.

So, as an example, the ideal scenario I think would be $XDG_DATA_HOME/hub/auth rather than the current $XDG_CONFIG_HOME/hub format.

I think storing it as a single file is fine IF it were to be the only file.

Was this page helpful?
0 / 5 - 0 ratings