1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 08:08:02 +00:00

Add Specify The Language For A File With Bat

This commit is contained in:
jbranchaud
2019-03-21 13:41:57 -05:00
parent 1307d05e7a
commit c4494b0c8a
2 changed files with 20 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
# Specify The Language For A File With Bat
The `bat` utility is able to correctly infer the language of most files it
prints based on the file extension. In some cases, you may want to specify a
language other than the one it guesses.
For instance, here is a React file printed with `bat`:
![bat with no CLI args](https://i.imgur.com/Jk0L6tB.png)
The `jsx` syntax doesn't look great because of the inferred language
highlighting doesn't account for it. We can get better results by telling
`bat` that the file should be parsed as `JavaScript (Babel)`.
![bat with language specified](https://i.imgur.com/yB1rYW4.png)
By including `--language=jsx` as a flag, `bat` uses a different language
parser and the output is now what I'm looking for.