Skip to content

Conversation

pd93
Copy link
Member

@pd93 pd93 commented Aug 14, 2025

Based on #2247

This takes the idea of having a config in $HOME and takes it further by:

  • Using $XDG_CONFIG_HOME instead of $HOME
  • Adding proper nested config support (including use of $HOME if its a parent).

@pd93 pd93 marked this pull request as ready for review August 14, 2025 23:01
@vmaerten
Copy link
Member

Regarding the code, and IMO how it should behave, the docs are wrong.

Configuration Reference
Task has multiple ways of being configured. These methods are parsed, in sequence, in the following order with the > highest priority last:

  1. Configuration files
  2. Environment variables
  3. Command-line flags

The local config file should override env variables, and that’s how it works now.
Personally, I think the priority should be:

  1. Global config file (HOME / XDG)
  2. Env variables (though this is tricky since we also have local env vars for experiments)
  3. Local config file
  4. CLI flags

I just don’t want env vars from my .zshrc to beat my local .taskrc.yml.

@vmaerten vmaerten self-requested a review August 15, 2025 09:33
@vmaerten
Copy link
Member

That being said, I totally forgot about XDG config, and I love this! Good job!
Nice refacto tho

@pd93
Copy link
Member Author

pd93 commented Aug 15, 2025

The local config file should override env variables, and that’s how it works now. Personally, I think the priority should be:

  1. Global config file (HOME / XDG)
  2. Env variables (though this is tricky since we also have local env vars for experiments)
  3. Local config file
  4. CLI flags

I don't see the distinction between a "local" file and one in the users home directory config. With a project path of $HOME/path/to/project, there could be config files in each of:

  • $HOME/path/to/project
  • $HOME/path/to
  • $HOME/path
  • $HOME

and they would all override one another with the more specific paths taking priority. I don't see why the one in $HOME should be treated differently.

I just don’t want env vars from my .zshrc to beat my local .taskrc.yml.

I can understand why the XDG config might be treated differently, but why not just have environment variables as the lowest priority then? I think its confusing to put env vars inbetween the two types of config in the priority order.

Thinking about it, is there any particular reason we need environment variables at all? Why would you apply settings in an rc file when you could just define a config?

@vmaerten
Copy link
Member

and they would all override one another with the more specific paths taking priority. I don't see why the one in $HOME should be treated differently.

Because a global env variable would take precedance over a config file located in the project (but See ⬇️ )

I can understand why the XDG config might be treated differently, but why not just have environment variables as the lowest priority then? I think its confusing to put env vars inbetween the two types of config in the priority order.

Thinking about it, is there any particular reason we need environment variables at all? Why would you apply settings in an rc file when you could just define a config?

Here we are! If you ask me, now that we have proper config files, env vars aren’t really needed anymore.
Aside from TASK_COLOR and TASK_TEMP_DIR, the rest are tied to experiments and could be removed.

That would simplify both our codebase and the user experience.

@pd93
Copy link
Member Author

pd93 commented Aug 15, 2025

Because a global env variable would take precedance over a config file located in the project (but See ⬇️ )

Ok, I think we're on the same page 👍

Here we are! If you ask me, now that we have proper config files, env vars aren’t really needed anymore. Aside from TASK_COLOR and TASK_TEMP_DIR, the rest are tied to experiments and could be removed.

Since config files are new, I assume we would put TASK_COLOR and TASK_TEMP_DIR as the lowest priority and nothing should break. We can then deprecate them.

Copy link
Member

@vmaerten vmaerten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed my two debug logs!
LGTM

@vmaerten vmaerten merged commit f89c12d into main Aug 18, 2025
15 of 19 checks passed
@vmaerten vmaerten deleted the home-taskrc-2 branch August 18, 2025 20:43
vmaerten added a commit that referenced this pull request Aug 18, 2025
@panchoh
Copy link

panchoh commented Aug 19, 2025

Hi, and sorry I’m late to the party!

Could I suggest (for another PR, but keeping this context) that we strip the initial dot in the taskcfg.yml that lives on $XDG_CONFIG_HOME/task?

Having a hidden file there only makes it harder to see it, and it is a common pattern. See for instance git: ~/.gitconfig vs. ~/.config/git/config.

Thanks for Task as well as this PR!!! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants