Hi! I’ve created a command-line tool that is capable of applying syntax highlighting to piped input and supports (work in progress) both sublime-syntax and sublime-color-scheme formats, so for example cat source.c | python3 hl.py -s C -c Celeste
would apply the C language syntax highlighting using the Celeste color-scheme to the output of cat source.c.
I find it very useful, above all when combined with a custom syntax applied for example to logs.
I thought it would be cool to share it with the community. You can find the source code at https://github.com/sublhighlight/sublhighlight.
Please, leave some feedback or open an issue or a PR.
Hope you’ll enjoy!
Sublime Syntax Highlighting for the Commandline
Thanks for sharing - looks interesting! I might be tempted to add some unit tests and support for syntax test files so we can check the correctness
Fwiw, this is my cat
and this is bat , which uses Sublime Text’s syntax definition v1 I believe or partially v2 maybe (I know it’s syntax engine doesn’t support branch
yet). Oh I see keith-hall is there.
alias cat='bat -pp --paging=never --style=plain --theme="Monokai Extended Origin"'
That would be great actually, I’m pretty much sure it would uncover some problems!
Syntax test files! I knew there must have been a way to test it, more info please!
https://www.sublimetext.com/docs/syntax.html#testing
There’s a Rust implementation here: https://github.com/trishume/syntect/blob/master/examples/syntest.rs
thank you, did skim over that too quickly to realise what it was actually saying.