sharkdp / bat

A cat(1) clone with wings.
Apache License 2.0
49.93k stars 1.26k forks source link

Add option that displays configurations. #2507

Open cohml opened 1 year ago

cohml commented 1 year ago

My bat config currently looks like this:

$ cat ~/.config/bat/config
--theme="TwoDark"
--style=changes,header-filename,rule,snip
--italic-text=always
--pager="less --chop-long-lines --header=1 --line-num-width=0 --LONG-PROMPT --no-number-headers --RAW-CONTROL-CHARS --shift=4 --status-column --use-color --color=HGk --color=NGk"
--wrap=never

Sometimes I want to remind myself what some of those fields are set to. So something like the following would be very handy:

$ bat --config
italic-text: always
pager: less --chop-long-lines --header=1 --line-num-width=0 --LONG-PROMPT --no-number-headers --RAW-CONTROL-CHARS --shift=4 --status-column --use-color --color=HGk --color=NGk
style: changes,header-filename,rule,snip
theme: TwoDark
wrap: never

Currently the quickest way to do this is the following, but it's unnecessarily involved:

$ cat $(bat --config-dir)/config

Bonus points for coloring the names of the fields so that they stand out, bat-style.

Double bonus points for the ability to filter the output by named field, such as this:

$ bat --config theme
TwoDark

This option may have niche appeal, but would surely be straightforward to add.

If I can ever get around to learning Rust, I will volunteer 😳

keith-hall commented 1 year ago

Currently the quickest way to do this is the following, but it's unnecessarily involved:

$ cat $(bat --config-dir)/config

Wouldn't the quickest way to do this be bat --diagnostic? Though it includes other stuff in the output, not just config. Maybe we could highlight that output as Markdown in the terminal if it doesn't conflict with it being easy to copy/paste into a GitHub issue :)

cohml commented 1 year ago

That could work in a pinch, coloring the output of --diagnostic. To be honest, that option was not on my radar.

If you are satisfied with that to the extent that a separate --config option would be redundant and not worth doing, feel free to close this issue.

LowLevelLover commented 1 year ago

I can implement the --config option, as it is a helpful option to access the current bat config easily.

LowLevelLover commented 1 year ago

Hey @keith-hall,

If you think adding this option to bat is useful, assign this issue to me please?

keith-hall commented 1 year ago

I'd be interested to hear what thoughts @sharkdp and @Enselic have on this matter, as opposed to just taking a decision by myself :)

Enselic commented 1 year ago

IMHO cat $(bat --config-dir)/config is not that much more complicated than bat --config. On the other hand, bat --config could perhaps take into account a system wide configs and environment variables when applicable.

Before a final decision it would be nice to see some draft code :)