Bat: No syntax detection for .bashrc

Created on 11 May 2018  路  12Comments  路  Source: sharkdp/bat

.bashrc et al. are listed as recognized filetypes, but have no colouring with bat when run without any options. That is, I expect that if I run bat ~/.bashrc that syntax highlighting would be enabled, but it isn't.

bug

All 12 comments

Thank you for your feedback!

I noticed the same thing recently with .gitconfig files. I think this is a bug / missing feature in syntect which I believe should be easy to fix. I will look into this.

Thanks! On a somewhat related note, it seems like zsh support is there, but .zshrc wasn't listed among the supported extensions.

Hm, bat ~/.zshrc does not work for me.

Btw, note that you can always use the --language/-l option:

bat -l sh ~/.bashrc

That was my point, that bat ~/.zshrc doesn't work. But it seems like it should since .bashrc is supported :) But I guess this a "bug" with syntect and not bat.

Thanks @sharkdp!

My PR has been merged in syntect, so .bashrc, .bash_profile, Makefile, Dokerfile, etc. should work now.

.zshrc does not work, as it is not part of the known file extensions / names.

Thanks! I'm guessing I should raise the .zshr issue with syntect?

syntect is probably not the right place to ask. We would need a .sublime-syntax file for .zshrc (or .zsh) files and add it here: https://github.com/sharkdp/bat/tree/master/assets/syntaxes

One potential problem with that is that the Bash syntax (https://github.com/sublimehq/Packages/blob/1cb4c3ec368c751d6f7ecfa16fe02ceff23a1f6b/ShellScript/Bash.sublime-syntax#L15) actually adds .zsh as a file extension (but not .zshrc). If this should also include .zshrc, we would have to ask here: https://github.com/sublimehq/Packages/

Another option is to add a mode-line to the top of your .zshrc file:

# -*- mode: shell-script -*-

Thanks for the pointer. I was looking around for where this was defined and I missed it here since I didn't do a recursive clone of the bat repo :) Anyway, I raised sublimehq/Packages#1583 to hopefully address this. Thanks!

Fixed in v0.4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sharkdp picture sharkdp  路  3Comments

lilyball picture lilyball  路  3Comments

yum-feng picture yum-feng  路  3Comments

mjlbach picture mjlbach  路  3Comments

yannallain picture yannallain  路  3Comments