Show HN: Clp, a Faster Alternative to Bat (jeskin.net)

4 points by jpe90 ↗ HN
This is a small hobby project that writes files to stdout with syntax highlighting.

My main use case is replacing bat for use in the preview window for the program fzf. I wanted to speed it up and support languages that didn’t meet bat’s inclusion criteria out of the box (myrddin, hare, etc)- more info in the blog post.

2 comments

[ 4.2 ms ] story [ 15.8 ms ] thread
Congrats on releasing this! I could compile & run this on my machine, works just fine. I'm a but confused about the use case. Bat opens a larger file in less or something, so I can jump through there and search for stuff. Clp doesn't do that, it just prints the files content with syntax highlighting. But sure, I can just type this:

    clp sqlite3.c | less -r
But when I do this, at least on my machine, bat feels a lot faster! The file reader opens up way faster. I guess what you're measured is something like:

    time bat --color=always sqlite3.c > /dev/null
    time clp sqlite3.c > /dev/null
With these commands, clp is actually 15 times faster, so I get the same measurement as you. But what is the use case for this? Are you piping the output of bat into something? In the beginning you explained your use case, but I didn't really get it.

Anyways, cool project! Should totally have a click bait title like "rewriting rust apps in lua makes them 15x faster."

Thank you for the kind words!

The use case for me is for a fzf preview window- you can see it in the last image in the blog post with the shell script used just above it.

If I use bat as my fzf previewer and move to a big file it’ll hang.

If you use bat standalone at the command line with it’ll open its built in pager instantly like you observed, but that doesn’t help with fzf. Also if you try to search or scroll to the bottom of the pager you’ll have a bad time.

https://github.com/junegunn/fzf#preview-window

My hat’s off to you on that title, that is masterful clickbait