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

Feature Request: Generate default config file #870

Closed
issmirnov opened this issue Mar 16, 2020 · 10 comments
Closed

Feature Request: Generate default config file #870

issmirnov opened this issue Mar 16, 2020 · 10 comments
Labels
feature-request New feature or request good first issue Good for newcomers

Comments

@issmirnov
Copy link
Contributor

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.

@issmirnov issmirnov added the feature-request New feature or request label Mar 16, 2020
@jyn514
Copy link

jyn514 commented Mar 17, 2020

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.

@eth-p
Copy link
Collaborator

eth-p commented Mar 18, 2020

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!

@sharkdp
Copy link
Owner

sharkdp commented Mar 18, 2020

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?

@jyn514
Copy link

jyn514 commented Mar 18, 2020

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

@sharkdp
Copy link
Owner

sharkdp commented Mar 18, 2020

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.

@issmirnov
Copy link
Contributor Author

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.

@sharkdp
Copy link
Owner

sharkdp commented Mar 26, 2020

Closed in #885 by @jmick414

@issmirnov
Copy link
Contributor Author

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

@sharkdp
Copy link
Owner

sharkdp commented Apr 22, 2020

released in bat v0.14

@GitMurf
Copy link

GitMurf commented Aug 7, 2024

Is it expected that on Windows the --generate-config-file creates a file C:\Users\USER_NAME\AppData\Roaming\bat\conf with the config file being named config without any extension? This was very confusing as I initially expected I should create a config folder and then have the config file go within it naming it something like config.conf or bat.conf due to this line in the README: export BAT_CONFIG_PATH="/path/to/bat.conf" which references a config file with a .conf extension.

The problem that occurred that took me a long time to troubleshoot is that since I had first created a folder config when I tried to run the bat --generate-config-file I kept getting a PowerShell error that access was denied. It wasn't until I deleted my config folder that then the command worked and it generated a config file as config without a file extension (as detailed above).

Thoughts? Is this expected?

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
Development

No branches or pull requests

5 participants