News for hackers. Stuff that matters.
Re:Bat: Cat with Syntax Highlighting by ikurei on Wednesday October 08, 2025 @03:23AM (#45513103)
Although I agree with other commenters that your command can't compare to all of bat's features, many of which I appreciate... thank you for sharing this tip, I didn't know about `highlight` and I can't install `bat` at work.

This will live in my .bashrc for a long time:

    cat() {
      if [[ -t 1 ]]; then
        command cat "$@" | highlight --force -O xterm256
      else
        # plain cat to pipe into other things
        command cat "$@"
      fi
    }
Re:Bat: Cat with Syntax Highlighting by dTal on Wednesday October 08, 2025 @04:56AM (#45513790)
This... doesn't work? Everything just comes out green. It's not clear to me how 'highlight' could even possibly know what syntax it's supposed to be highlighting when processing stdin, unless it ingests the whole thing until EOF and then applies some kind of fuzzy logic. If you feed it a filename as an argument, it just checks the extension.
Re:Bat: Cat with Syntax Highlighting by em-bee on Wednesday October 08, 2025 @11:50PM (#45523294)
curious, how did you have highlight installed?

i'd change the third line:

    command highlight --stdout --force -O xterm256 "$@"