Live data from Hacker News

An Illustrated Guide to Useful Command Line Tools

wezm.net

21–30 of 108 posts

Re: An Illustrated Guide to Useful Command Line Tools

#21

Can someone explain the misuse of cat, which bat solves?

Simply using cat to dump a single file to STDOUT is technically a misuse because cat is theoretically intended to concatenate files. This 'misuse' is 'solved' by bat because bat seems to be primarily intended for its syntax highlighting and git-related features; according to bat's docs, cat-style concatenation of files is intended for drop-in compatibility with traditional cat.

That said, the idea that using cat to show a single file is "misusing" cat is prescriptivist rules-lawyering. There is no technical reason against using cat for non-concatenation purposes. The descriptivist interpretation of cat says using the tool for non-concatenation purposes is fine, since that's how people are actually using it.

However, note that cat is often misused as a substitute for STDIN redirection:

    # this creates an extra process that wastes
    # time copying STDIN to STDOUT
    cat "${inputfile}" | do_stuff

    # just connect inputfile directly to STDIN
    do_stuff 

Re: An Illustrated Guide to Useful Command Line Tools

#22

Lots of cool stuff in here. I’m going to have a long look at Restic and Syncthing. I’d like to know why Skim instead of FZF. They are pretty similar but I’ve been using the latter for years and would like to know of any possible advantages to it.

There's a lot of these pickers and they are indeed similar. I've been using https://github.com/jhawthorn/fzy since it's not fullscreen and has a really good matching algorithm.

Re: An Illustrated Guide to Useful Command Line Tools

#23

Earlier quoted context omitted.

Maybe, but I already had pygmentize , I already had less , and this small function took me less than 10 seconds to type in and start using immediately (and I use a particular style that pygmentize provides so that is a plus). :P In any case, thanks for sharing.

Oh, I forgot to mention that LESSPIPE is a mechanism to automatically pipe the contents of a file when opening in less, and that the linked LESSPIPE script has an option to use pigmentize for syntax highlighting. It’s a tool for enhancing less & pygmentize, not replacing them. Well, just providing info for everyone. I’m not trying to force you using that script :-)

> Well, just providing info for everyone. I’m not trying to force you using that script :-)

Yeah of course, sorry, I admit my comment did seem defensive! Thank you for sharing, really. :)

Re: An Illustrated Guide to Useful Command Line Tools

#24
post #16

A number of the utilities mentioned here (bat, fd, hexyl) are made by the same author, who makes a number of additional command line utilities in Rust. They're all rather easy to use and aesthetically pleasing, I'm a fan of their work: https://github.com/sharkdp

Indeed! I'm a fan of hyperfine and bat, and I've been meaning to check out pastel when I have more time...

Re: An Illustrated Guide to Useful Command Line Tools

#26

Can someone explain the misuse of cat, which bat solves?

Google "UUOC" - it's famous. Edit: Sorry downvoter, thought I was being helpful - no-one mentioned the acronym yet. There's a lot online about it, more than I'm qualified to explain. Entertaining reading too. I remember reading about the UUOC Awards years ago..

[deleted]

Re: An Illustrated Guide to Useful Command Line Tools

#29

Lots of cool stuff in here. I’m going to have a long look at Restic and Syncthing. I’d like to know why Skim instead of FZF. They are pretty similar but I’ve been using the latter for years and would like to know of any possible advantages to it.

I've tried both Skim and fzf, and in my experience fzf has a much better fuzzy matching algorithm so that's what I'd recommend using. Plus it supports true color configuration fwiw.

Re: An Illustrated Guide to Useful Command Line Tools

#30

Can someone explain the misuse of cat, which bat solves?

I guess the author was thinking of how cat's original purpose is to concatenate multiple files, not show just one file. (But I certainly don't think using cat in the latter way is a misuse.) There's also a commonly noted "unnecessary use of cat" where people do this: cat file.txt | grep foo instead of this: but that's not relevant to bat (which can be used unnecessarily in the same way).

Or ‘grep foo file.txt’
Post reply on HN