Repository navigation
Honour XDG_CONFIG_HOME on every platform - #18
Merged
Merged
Conversation
The config file was found through `dirs::config_dir()`, which ignores `XDG_CONFIG_HOME` on macOS and always returns `~/Library/Application Support`. When `XDG_CONFIG_HOME` is set to an absolute path, use `$XDG_CONFIG_HOME/unifi/config.toml` instead. Empty and relative values are ignored, as the [XDG Base Directory spec](https://specifications.freedesktop.org/basedir/) requires. If the XDG file doesn't exist yet but the platform default does, keep reading the platform file so an existing config isn't dropped. `config init` always writes to the XDG path, seeding it with the profiles from the platform file and leaving that file in place. Noticed `completions fish --install` used `dirs::config_dir()` as well, so on macOS it wrote to `Application Support/fish/completions`, which fish never reads. It now writes to `$XDG_CONFIG_HOME/fish/completions`, or `~/.config/fish/completions` when the variable is unset.
rvben
force-pushed
the
feature/xdg-config-dir
branch
from
November 12, 2026 10:28
bc9bdff to
7ba6a98
Compare
rvben
enabled auto-merge (squash)
November 12, 2026 10:28
Owner
|
Thanks for the contribution and the tests! Merged and released in v0.5.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Neat tool, means I didn't have to hack together something myself. 🎉
On macOS, I set
XDG_CONFIG_HOME, and this wasn't respected by unifi-cli, and I really wanted it to, so I made it so. I also added a bunch of tests.If you want to change anything, feel free, hoping this helps.
Also noticed
completions fish --installon macOS wrote toApplication Support/fish/completions, which fish never reads, it now writes to$XDG_CONFIG_HOME/fish/completions, or~/.config/fish/completionswhen the variable is unset. (I use zsh, but 🤷 )