bat
bat copied to clipboard
Separate system and user config files
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.
Sounds like a good idea to me! Thank you for the feedback.
Adding a quick note for #659: This should probably be configurable by the package maintainer.
I am very new to Rust, like very very new new. Can I try my hands on this if that's okay?
Sure! Let us know if you need help
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 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.
Hi @sharkdp so, this how I am thinking of approaching this: I would just concatenate config read from
/etc/bat/configand~/.config/bat/configtogether
You could use bat to concatenate those files, right ? 😉
Is this issue still active? I can see #691 which was closed a while back. I'm keen to pick this up :)
This is still active, yes.
Should /etc/bat/config be static or should we expose an env var to override that also?
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?
Y'all Crazy 🤣🤣🤣
Y'all Crazy 🤣🤣🤣
Off-topic.
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 WindowsNo 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
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.
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.
Does this include support for /etc/bat/syntaxes/, too, or only /etc/bat/config?