A cat(1) clone with syntax highlighting and Git integration.
$ bat README.md
bat
supports syntax highlighting for a large number of programming and markup
languages:
bat
communicates with git
to show modifications with respect to the index
(see left side bar):
You can install on Debian/Ubuntu os with:
$ apt-get install bat
or
Go to [https://github.com/sharkdp/bat/releases/](https://github.com/sharkdp/bat/releases/) and take the good version for you EG:
$ wget https://github.com/sharkdp/bat/releases/download/v0.13.0/bat_0.13.0_amd64.deb
$ dpkg -i bat_0.13.0_amd64.deb
$ bat src/*.rs
$ curl -s https://sh.rustup.rs | bat
$ yaml2json .travis.yml | json_pp | bat -l json
$ bat -A /etc/hosts
$ bat > note.md # quickly create a new file
$ bat header.md content.md footer.md > document.md
$ bat -n main.rs # show line numbers (only)
$ bat f - g # output 'f', then stdin, then 'g'.
You can use the -exec option of find to preview all search results with bat:
find … -exec bat {} +
If you happen to use fd, you can use the -X/--exec-batch option to do the same:
$ fd … -X bat
$ batgrep needle src/
$ tail -f
bat can be combined with tail -f to continuously monitor a given file with syntax highlighting.
$ tail -f /var/log/pacman.log | bat --paging=never -l log
Note that we have to switch off paging in order for this to work. We have also specified the syntax explicitly (-l log), as it can not be auto-detected in this case. $ git You can combine bat with git show to view an older version of a given file with proper syntax highlighting:
$ git show v0.6.0:src/main.rs | bat -l rs
Note that syntax highlighting within diffs is currently not supported. If you are looking for this, check out delta.
$ bat README.md
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: README.md
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ # Bash3lper
2 │
3 │ Bash3lper
4 │
5 │
6 │ _____ _ ____ _ __ __
7 │ | ____|___| |__ ___/ ___| _ _ ___| |_ ___| \/ |
8 │ | _| / __| '_ \ / _ \___ \| | | / __| __/ _ \ |\/| |
9 │ | |__| (__| | | | (_) |__) | |_| \__ \ || __/ | | |
10 │ |_____\___|_| |_|\___/____/ \__, |___/\__\___|_| |_|
11 │ |___/
12 │
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────