Bat: Feature Request: Generate default config file

Created on 16 Mar 2020  路  9Comments  路  Source: sharkdp/bat

Branching off from #573 - it would be very useful if bat automatically generated a sane, small, well commented config file for users.

For example:

  • bat --config-file -o $file writes to $file
  • bat --generate-config-file writes to the current default config location and prints the path

I assume the implementation would be a small static string or binary blog baked into the binary. Not sure how rust does these things.

feature-request good first issue

Most helpful comment

I don't think the -o option is necessary here, you can already redirect the output with > at the command line. The other options look useful though.

All 9 comments

I don't think the -o option is necessary here, you can already redirect the output with > at the command line. The other options look useful though.

I assume the implementation would be a small static string or binary blog baked into the binary. Not sure how rust does these things.

include_str! or include_bytes!

I don't think the -o option is necessary here, you can already redirect the output with > at the command line. The other options look useful though.

Good point, but then how should the CLI really look like?

I would expect --config-file to always write to standard out. Does that answer your question?

Not really.

bat --config-file

currently prints the path to the config file, and we are not planning to change that.

The idea of this ticket is to create a new way to generate a default config file, ideally at the place where bat would look for it anyway.

My question is how we want to design the CLI to allow users to do that.

If we are implementing something like bat --print-default-config-file which prints to the console, are we advising users to run something like this?

bat --print-default-config-file > bat --config-file

That wouldn't really work because the ~/.config/bat folder would likely not exist.

Agree with @sharkdp above - that seems pretty clunky. My vote is on this:

$ bat --generate-config-file
Success! Config file written to ~/.config/bat/bat.conf

Under the hood, this command creates the ~/.config/bat folder and writes the config file.

Closed in #885 by @jmick414

Woohoo! You guys rock. Thanks @jmick414 and @sharkdp .

released in bat v0.14

Was this page helpful?
0 / 5 - 0 ratings

Related issues

antoinemadec picture antoinemadec  路  3Comments

x70b1 picture x70b1  路  3Comments

tomgoren picture tomgoren  路  3Comments

HakubJozak picture HakubJozak  路  3Comments

gAmUssA picture gAmUssA  路  3Comments