Add support for ~/.config/lazygit without setting XDG_CONFIG_HOME on macOS #3989
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.
Currently lazygit looks for its config file in
XDG_CONFIG_HOME
if it's available, but if not it falls back to the defaults defined by the xdg package. Unfortunately the defaults the package falls back to isn't what CLI applications commonly fall back to on macOS. Specifically, it looks in~/Library/Application Support
instead of~/.config
.This updates the app config logic to:
~/.config/lazygit
first ifXDG_CONFIG_HOME
is not set and we're on macOS.xdg
package location if the configuration file exists there.~/.config/lazygit/config.yml
ifXDG_CONFIG_HOME
is not set, we're on macOS, and there is no existing configuration file.This change did feel a bit like having to thread a needle and I didn't see any existing tests for this behavior (which is reasonable, since it's complicated and OS dependent) so I did test a few variations of the configuration locally by building with this change included and comparing against a
brew
installed lazygit.It seemed to work properly, falling back to the existing location when
XDG_CONFIG_HOME
isn't set, using~/.config/lazygit
whenconfig.yml
is present, and creating~/.config/lazygit/config.yml
when it's not.I think this should resolve #1341
go generate ./...
)