Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate system and user config files #668

Closed
clarfonthey opened this issue Sep 21, 2019 · 17 comments · Fixed by #1888
Closed

Separate system and user config files #668

clarfonthey opened this issue Sep 21, 2019 · 17 comments · Fixed by #1888
Labels
feature-request New feature or request good first issue Good for newcomers

Comments

@clarfonthey
Copy link
Contributor

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.

@eth-p eth-p added the feature-request New feature or request label Sep 21, 2019
@sharkdp
Copy link
Owner

sharkdp commented Sep 21, 2019

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

@sharkdp sharkdp added the good first issue Good for newcomers label Sep 21, 2019
@eth-p
Copy link
Collaborator

eth-p commented Sep 27, 2019

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

@goku321
Copy link

goku321 commented Oct 7, 2019

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

@sharkdp
Copy link
Owner

sharkdp commented Oct 7, 2019

Sure! Let us know if you need help

@goku321
Copy link

goku321 commented Oct 12, 2019

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

@sharkdp
Copy link
Owner

sharkdp commented Oct 13, 2019

@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.

@etiennemabille
Copy link

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 ? 😉

@morgsmccauley
Copy link

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

@sharkdp
Copy link
Owner

sharkdp commented Oct 1, 2020

This is still active, yes.

@morgsmccauley
Copy link

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

@sharkdp
Copy link
Owner

sharkdp commented Oct 9, 2020

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?

@Teehmon684

This comment has been minimized.

@thecaralice

This comment has been minimized.

akinnane added a commit to akinnane/bat that referenced this issue Mar 12, 2021
akinnane added a commit to akinnane/bat that referenced this issue Mar 12, 2021
akinnane added a commit to akinnane/bat that referenced this issue Mar 12, 2021
@Enselic
Copy link
Collaborator

Enselic commented Mar 12, 2021

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 😖

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

@septa97
Copy link

septa97 commented Sep 4, 2021

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.

patrickpichler pushed a commit to patrickpichler/bat that referenced this issue Oct 6, 2021
There is now support for a systemwide config file. The location of the
system wide config file is `$(BAT_SYSTEM_CONFIG_PREFIX)/bat/config`.
`$(BAT_SYSTEM_CONFIG_PREFIX)` has to be provided at compile time as an
environment variable. If the environment variable is not set, a default
is used. This default is `C:` for windows and `/etc` for every other os.

fixes sharkdp#668
@patrickpichler
Copy link

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 pushed a commit to patrickpichler/bat that referenced this issue Oct 6, 2021
There is now support for a systemwide config file. The location of the
system wide config file is `$(BAT_SYSTEM_CONFIG_PREFIX)/bat/config`.
`$(BAT_SYSTEM_CONFIG_PREFIX)` has to be provided at compile time as an
environment variable. If the environment variable is not set, a default
is used. This default is `C:\ProgramData` for windows and `/etc` for
every other os.

fixes sharkdp#668
patrickpichler pushed a commit to patrickpichler/bat that referenced this issue Oct 6, 2021
There is now support for a systemwide config file. The location of the
system wide config file is `$(BAT_SYSTEM_CONFIG_PREFIX)/bat/config`.
`$(BAT_SYSTEM_CONFIG_PREFIX)` has to be provided at compile time as an
environment variable. If the environment variable is not set, a default
is used. This default is `C:\ProgramData` for windows and `/etc` for
every other os.
@sharkdp sharkdp added this to the v0.19 milestone Nov 22, 2021
@Enselic Enselic removed this from the v0.19 milestone Mar 3, 2022
@mazunki
Copy link

mazunki commented Mar 25, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request good first issue Good for newcomers
Projects
None yet