bat
bat copied to clipboard
support vi ft comments
Sadly, not all file types encode their file type as an extension. Even worse, a lot of files use meaningless extensions where you have to look at their directory. For example, systemd uses environment.d/*.conf for .env files, that could also be parsed as .sh because they also allow for simple interpolation.
Would be cool to support the vi way for being able to use a comment to define it. Suggesting specifically this because many files may already have it, and/or it serves another purpose.
https://unix.stackexchange.com/a/19869/29
e.g.
# vi: ft=gitconfig
This has been requested a few times. Please see #1732, for example.
Even worse, a lot of files use meaningless extensions where you have to look at their directory. For example, systemd uses
environment.d/*.conffor.envfiles, that could also be parsed as.shbecause they also allow for simple interpolation.
You can actually tell bat to map paths like this to a specific syntax. For your example, you would have to add something like
--map-syntax '**/environment.d/*.conf:Bourne Again Shell (bash)'
to bats config file.
bat actually highlights these systemd files with the INI syntax currently (see https://github.com/sharkdp/bat/pull/1060). Let us know if you think this can be improved.
looks pretty flat on my system, ;) and they're closer to sh than INI, afaik. Obviously the're an example. I've seen some .conf files recently that I'm not even sure what they are...
--map-syntax '**/environment.d/*.conf:Bourne Again Shell (bash)'
Could we shorten this to --map-syntax '**/environment.d/*.conf:bash' ?
Duplicate of #160
... which is closed. It maybe should be reopened.
Either way, this is a duplicate of that one.
Duplicate of #160