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 <"${inputfile}"
# or if you want to keep the input
# at the start of the pipeline
<"${inputfile}" do_stuffThere's also a commonly noted "unnecessary use of cat" where people do this:
cat file.txt | grep foo
instead of this: <file.txt grep.foo
but that's not relevant to bat (which can be used unnecessarily in the same way).For instance:
$ echo -e "\033]0;${USER} is an unfriendly person\007" > test-file.txt
Then, many days later: $ cat test-file.txt
will change your terminal title.With less, you _can_ interpret escape codes, but usually you don't, and I consider this the correct default.
What is clear is that
$ cat test-file.txt
does not print the initially-echoed text, but it is escaped and up to nefarious tasks. cless() {
pygmentize -O style=<style> "$1" 2>/dev/null | less
}
I have programs that depend on pygmentize so I am not sure I will use bat anytime soon when I already have pygmentize and less, or at least not for it having 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 :-)
Yeah of course, sorry, I admit my comment did seem defensive! Thank you for sharing, really. :)
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..