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

Allow for the config file to have a file extension #3203

Open
thernstig opened this issue Feb 7, 2025 · 4 comments
Open

Allow for the config file to have a file extension #3203

thernstig opened this issue Feb 7, 2025 · 4 comments
Labels
feature-request New feature or request

Comments

@thernstig
Copy link

thernstig commented Feb 7, 2025

It would be nice if the file placed at .config/bat/config allowed for a file extension. This helps editors to automatically syntax highlight the contents, such as VS Code.

I assume the language of the file is ini?

@thernstig thernstig added the feature-request New feature or request label Feb 7, 2025
@keith-hall
Copy link
Collaborator

bat uses the bash syntax to highlight it's own config file.
You can use whatever file extension you like, just set the BAT_CONFIG_PATH env var as outlined at https://github.com/sharkdp/bat?tab=readme-ov-file#configuration-file

@thernstig
Copy link
Author

thernstig commented Feb 8, 2025

@keith-hall understood, but it would make sense to add a file extension to indicate what file format it is? It is quite common for a plethora of other tools that use XDG_CONFIG_HOME/something/someconfig.ext, such as chezmoi, eza, uv etc.

The benefit is immediate recognition of the format without having to set any extra BAT_CONFIG_PATH. In addition it is possible XDG_CONFIG_HOME differs between machines in worst case, meaning you'd have to do an extra BAT_CONFIG_PATH per machine.

I think it makes far more sense to use a default extension.

Aside: Is the file format bash correct? E.g. ShellCheck complains if trying that:

Image

@keith-hall
Copy link
Collaborator

Well the bat config format is really just arguments to the bat executable, so having bat at the beginning is kinda implied, so I can see why ShellCheck would complain. Especially as there's no need for line continuation characters either. But that perhaps also explains why it doesn't have an extension by default. It isn't really a bash script which can be executed directly.
If we did settle on a default extension, I imagine seamless backwards compatibility with existing extensionless config files could be hard or confusing to achieve...

@thernstig
Copy link
Author

@keith-hall isn't the config though really adhering to the ini format? Or at least, a subset of it. Using ini in e.g. VS Code makes everything look nicely for the settings I have tried. Though I guess "it almost looks like ini" might not be a valid reason to set the default to ini.

Maybe using .toml would be a nice option for you to consider? If there is a file called bat.toml you would parse it as TOML? 🙂

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
Projects
None yet
Development

No branches or pull requests

2 participants