3 ms·
Maybe I'm completely missing the point of `bat` but I usually just use `view` (vim/neovim in readonly mode) if I want to read files with syntax highlighting, Gi
by lillesvin 7y ago
Maybe I'm completely missing the point of `bat` but I usually just use `view` (vim/neovim in readonly mode) if I want to read files with syntax highlighting, GitGutter, line numbers, etc.
- C0d3r 7y agoBat works the same way as ls when it's being piped. But it has better default features than cat, the syntax, numbers and the pager. if the file doesn't fit the screen, it becomes paged, so you don't have to do the whole: `cat file.txt` (too big), `view file.txt`
- awake 7y agoNot sure if view lets you do this but bat will switch off highlighting if you are piping output `bat file.txt | grep ...`. This makes it easy to make an alias cat=bat and have everything work. Also you can make bat display output with `less` and then line numbers can be toggled, not sure about gitgutter.
- sharkdp 7y ago(author of bat here) Exactly. Drop-in compatibility with 'cat' is one of the goals of bat (see https://github.com/sharkdp/bat#project-goals-and-alternatives https://github.com/sharkdp/bat#project-goals-and-alternative... and a list of alternatives here: https://github.com/sharkdp/bat/blob/master/doc/alternatives.md https://github.com/sharkdp/bat/blob/master/doc/alternatives....). Another thing that I use frequently is previewing a whole set of files in a single (pager) output. Something like bat src/*.cpp This also allows you to easily search across a whole set of open files.
- OskarS 7y agoAwesome work. I've been a happy user of bat for a few months now, I've almost totally trained my brain away from typing cat.
- OskarS 7y agoIt's a similar idea to that, but it's more lightweight and much more of a "drop-in replacement" for both cat and less. For instance, when using it as a replacement for "less", it will use terminal colors correctly (i.e. "ls --color | bat" works like you'd want), it will have the same keybindings as less (i.e. b/f for page back/forward, / for search, q for quit, ...), it wont have a cursor, etc. Essentially "less and cat but way better". Vim can certainly do all these things (or mostly, I don't know about the terminal colors), but for viewing read-only text streams, it's a bit more domain-specific and convenient. It's also blazing fast to open, which vim isn't always.