bat icon indicating copy to clipboard operation
bat copied to clipboard

Separate system and user config files

Open clarfonthey opened this issue 6 years ago • 16 comments

I've been trying to export most of my dotfile-type configs to system packages I can install. A lot of programs offer the option for both a system and a user config (e.g. git reads from /etc/gitconfig, then ~/.gitconfig) although currently, bat reads just one file. It'd be nice if we could do something similar for bat as well, loading both /etc/bat/config and ~/.config/bat/config.

clarfonthey avatar Sep 21 '19 00:09 clarfonthey

Sounds like a good idea to me! Thank you for the feedback.

sharkdp avatar Sep 21 '19 08:09 sharkdp

Adding a quick note for #659: This should probably be configurable by the package maintainer.

eth-p avatar Sep 27 '19 17:09 eth-p

I am very new to Rust, like very very new new. Can I try my hands on this if that's okay?

goku321 avatar Oct 07 '19 20:10 goku321

Sure! Let us know if you need help

sharkdp avatar Oct 07 '19 20:10 sharkdp

Hi @sharkdp so, this how I am thinking of approaching this: I would just concatenate config read from /etc/bat/config and ~/.config/bat/config together

goku321 avatar Oct 12 '19 17:10 goku321

@goku321 Yes, exactly. I think we should directly implement it with a list of possible paths to read from, in case there will be more (maybe OS-specific) paths in the future.

sharkdp avatar Oct 13 '19 07:10 sharkdp

Hi @sharkdp so, this how I am thinking of approaching this: I would just concatenate config read from /etc/bat/config and ~/.config/bat/config together

You could use bat to concatenate those files, right ? 😉

etiennemabille avatar Oct 30 '19 13:10 etiennemabille

Is this issue still active? I can see #691 which was closed a while back. I'm keen to pick this up :)

morgsmccauley avatar Sep 23 '20 20:09 morgsmccauley

This is still active, yes.

sharkdp avatar Oct 01 '20 18:10 sharkdp

Should /etc/bat/config be static or should we expose an env var to override that also?

morgsmccauley avatar Oct 08 '20 03:10 morgsmccauley

I would try to avoid introducing more environment variables, if possible. What do other CLI applications do? Is /etc/bat/config a reasonable place for a system-wide bat config?

sharkdp avatar Oct 09 '20 20:10 sharkdp

Y'all Crazy 🤣🤣🤣

Teehmon684 avatar Dec 19 '20 09:12 Teehmon684

Y'all Crazy 🤣🤣🤣

Off-topic.

magistau avatar Dec 19 '20 14:12 magistau

So out of curiosity, what would the system config paths be on the different platforms? Are there any standard conventions?

I think these might be reasonable:

* `/etc/bat/config` on Linux

* `<INSTALL_DIR>/config` on Windows

No idea for macOS.

I propose that we use git as the role model for where to put the system config file.

% man git-config
[...]
       $(prefix)/etc/gitconfig
           System-wide configuration file.
[...]

This path is used both for Linux and macOS (so #[cfg(unix)] can be used in Rust code).

I agree with @eth-p that we need to include means to specify $(prefix) somehow, but to be honest I don't know of the best way to do that within the Rust ecosystem.

I am also a bit skeptical towards putting things in a bat dir in /etc/ since the name bat is used for other packages too. On the other hand, it feels awkward to call it something like /etc/batcat :confounded:

When it comes to the Windows path, I don't have access to a machine to test on, but apparently

On windows this file can be found at C:\Documents and Settings\All Users\Application Data\Git\config on Windows XP, and in C:\ProgramData\Git\config on Windows Vista and newer.

I do think we need to put some extra effort into getting this right, since what we end up with is likely to stay around as a maintenance/backwards compatibility commitment for a long time.

CC @akinnane

Enselic avatar Mar 12 '21 08:03 Enselic

I planning to pick this up. But I have a major inquiry since I'm still very new to Rust and to open-source in general:

What is $(prefix) in the context of Git? My understanding from the man page and this stackoverflow question, it is an environment variable.

septa97 avatar Sep 04 '21 06:09 septa97

I've implemented a first draft of this. The prefix can be specified at compile time via an environment variable. If the variable is not set, a default is value is used.

I'm not 100% certain where to put this on windows though.

patrickpichler avatar Oct 06 '21 18:10 patrickpichler

Does this include support for /etc/bat/syntaxes/, too, or only /etc/bat/config?

mazunki avatar Mar 25 '23 15:03 mazunki