martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
9.32k stars 321 forks source link

FR: allow multiple user config files #4926

Open mikejsavage opened 2 days ago

mikejsavage commented 2 days ago

Hi,

I develop on several computers and would like to be able to have machine specific jj configs.

I will preface this by saying it's not very important and you can already do it with machine specific shell aliases and --config-toml.

Generally software lets you do this by having a shared main config, which includes a local config (which might not exist) with machine specific stuff in, e.g. for git in WSL I have:

> cat ~/.gitconfig
...
[include]
    path = .gitconfig.local
> cat ~/.gitconfig.local
[core]
        fileMode = false

Less commonly, some software (fish shell) loads everything from a config dir in alphabetical order, so you can do 0-base.fish/1-local.fish to achieve the same thing.

For a concrete example of why this would be helpful for jj, I have [ui] paginate = "never" on Windows because jj launches the pager when everything would fit on one screen and my WSL pager renders escape chars as ESC, making jj quite unusable

shanesveller commented 2 days ago

I make use of Git's includeIf to set things like user.email or commit templates based on whether a project is personal/OSS/professional, and I miss that opportunity as well as basic includes as mentioned here.

yuja commented 2 days ago

We'll add some includeif-like feature, but the implementation isn't started yet. https://github.com/martinvonz/jj/issues/616

martinvonz commented 1 day ago

We also have a TODO about maybe reading all config files in ~/.config/jj/ (I think we would simply delete the config_dir.push("config.toml"); line): https://github.com/martinvonz/jj/blob/a6c18e8353d12085abe5e03f210987430f4ebd53/cli/src/config.rs#L416-L422

As a workaround, you can actually already set $JJ_CONFIG to a directory path and we'll read all files from there.