Hacker News new | ask | show | jobs
by 149765 844 days ago
Why not just "fd -e fi.md -X batcat"?
2 comments

Good first idea, and I just tried it - but sadly, this opens every Markdown document at once, as a giant pile of documents I would have to scroll down through.

That's not what I'm after. I want to survey the whole page with my eyes as fast as possible for unusual colors / oddly short files / etc, then press `q` to have the screen totally clear and move on to the next one.

Why not `find -name '*.fi.md' -exec less {} \;`
find is pretty slow compared to fd. It also spends a lot of time searching through directories like .git or node_modules which you typically want to exclude.
The bottleneck for speed will be the human examining the documents so there really isn't any difference in the overall time spent. Even without the required human input it doesn't make much difference for such a small amount of files. Most of the time there isn't a much reason to use `fd` or `rg` over more standard tools. Often you get most of the benefit from a single `cd`. When making a script for general consumption and there are possibly larger collective time savings from excluding subdirectories it would make more sense to use `-prune` rather than a niche tool with default rules that might change in the future.
Can less provide syntax highlighting?
Sort of. Setting the LESSOPEN environment variable will filter less input through that, which could do syntax highlighting (if you use less -r).

The default (/usr/bin/lesspipe.sh, shipped with less) isn't very clever. It can uncompress files in some common formats and open images, but isn't very smart and doesn't handle markdown or code of any kind as far as I can tell.

It can with lesspipe but don't you think that's a bit of an overkill for a simple markdown document?