bat-extras icon indicating copy to clipboard operation
bat-extras copied to clipboard

feature: support bat's `--language` option

Open minhtrancccp opened this issue 10 months ago • 2 comments
trafficstars

when i batgrep generic files, e.g. *.txt, the matching text isn't highlighted since bat is not aware which language the file is. it would be great if the file's language could be passed to bat via the --language option, starting with batgrep. many thanks.

minhtrancccp avatar Jan 12 '25 03:01 minhtrancccp

Is it possible to provide an example of what you mean?

With batgrep, bat is given the the full file name and should be able to correctly detect the syntax based on the file extension. For example, running BAT_THEME='OneHalfLight' ./src/batgrep.sh bat in this repo will correctly highlight Markdown and shell scripts based on their file names:

Image

eth-p avatar Feb 22 '25 01:02 eth-p

i think the --language is most useful when piping into batgrep

Ezall2001 avatar May 29 '25 10:05 Ezall2001