I’m a big fan of
bat as a
cat replacement, and I’m an even bigger fan of
just as a Make replacement. Sadly,
bat doesn’t (and won’t) support Justfile syntax. But you can add it yourself with a little extra effort.
The first key insight is that
bat uses Sublime Text themes and you can just add them to “
$(bat --config-dir)/syntaxes” (in my case “
And fortunately, a theme for Justfiles already exists: just_sublime!
You should be able to run the following and have it working:
$ mkdir -p "$(bat --config-dir)/syntaxes" $ cd "$(bat --config-dir)/syntaxes" $ git clone https://github.com/nk9/just_sublime.git Cloning into 'just_sublime'... remote: Enumerating objects: 446, done. remote: Counting objects: 100% (151/151), done. remote: Compressing objects: 100% (67/67), done. remote: Total 446 (delta 94), reused 120 (delta 82), pack-reused 295 Receiving objects: 100% (446/446), 4.04 MiB | 14.88 MiB/s, done. Resolving deltas: 100% (263/263), done.
However, syntect, the package that does the parsing for
bat hasn’t implemented all necessary features yet, so adding it to
$ bat cache --build No themes were found in '/Users/hynek/.config/bat/themes', using the default set [bat error]: /Users/hynek/.config/bat/syntaxes/just_sublime/Syntax/Embeddings/Python (for Just).sublime-syntax: Missing mandatory key in YAML file: match
My limited understanding is that these Embeddings are for recursive highlighting (in this case Python blocks which you can use in Justfiles recipes) and just_sublime is shipping two of them: one for Python and one for shell scripts.
Both are incompatible with
bat, so let’s delete them and try again:
$ rm \ 'just_sublime/Syntax/Embeddings/Python (for Just).sublime-syntax' \ 'just_sublime/Syntax/Embeddings/ShellScript (for Just).sublime-syntax' $ bat cache --build No themes were found in '/Users/hynek/.config/bat/themes', using the default set Writing theme set to /Users/hynek/.cache/bat/themes.bin ... okay Writing syntax set to /Users/hynek/.cache/bat/syntaxes.bin ... okay Writing metadata to folder /Users/hynek/.cache/bat ... okay
And it works1:
I hope this brief guide gives you the necessary momentum that I was lacking while living with boring plain Justfiles output for months!
Well, mostly. The body of the recipe isn’t highlighted because that would’ve been the job of the files we’ve deleted. ↩︎