4 ms·
Bat is a file viewer that supports syntax highlighting and reads git status to also annotate added/deleted/changed lines. The classic file viewer for a termina
by emil-lp 1y ago
Bat is a file viewer that supports syntax highlighting and reads git status to also annotate added/deleted/changed lines.
The classic file viewer for a terminal is cat (or less).
- goku12 1y agoJust a nitpick. The real use of cat is to concatenate two or more files and dump the result in its stdout. But people use it more like file viewer these days. Bat is a file viewer in every sense. I have concatenated multiple files using bat. It does come in handy sometimes. But even the concatenated output is designed to be a visual aid, not the traditional concatenation that cat does.
- JohnKemeny 1y agoJust a nitpick. They said the classic file viewer is cat, not that cat's primary purpose was viewing files.
- chiffaa 1y agoTo be 100% fair, Bat only acts this way when used in an interactive environment. As far as I know, in non-interactive cases (a la shell scripting) it falls back to normal cat behaviour
- goku12 1y agoThat's interesting! How did you know?
- chiffaa 1y agoTheir README claims the following > Whenever bat detects a non-interactive terminal (i.e. when you pipe into another process or into a file), bat will act as a drop-in replacement for cat and fall back to printing the plain file contents which was good enough for me personally, but I also have seen anecdotal evidence of people running `alias cat=bat` with a bunch of your usual bash piping work without any issues