BAT

tool bat

Build Status license Version info
A cat(1) clone with syntax highlighting and Git integration.

Display a single file on the terminal

$ bat README.md

Syntax highlighting

bat supports syntax highlighting for a large number of programming and markup languages:

Syntax highlighting example

Git integration

bat communicates with git to show modifications with respect to the index (see left side bar):

Git integration example

Installation

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

Display multiple files at once

$ bat src/*.rs

Read from stdin, determine the syntax automatically

$ curl -s https://sh.rustup.rs | bat

Read from stdin, specify the language explicitly

$ yaml2json .travis.yml | json_pp | bat -l json

Show and highlight non-printable characters:

$ bat -A /etc/hosts

Use it as a cat replacement:

$  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'.

Integration with other tools

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

ripgrep

With batgrep, bat can be used as the printer for ripgrep search results.

 $  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   │
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Previous Post Next Post