Replace Cat With Bat

When using Linux, I often use cat to browse some short codes. But it doesn't support syntax highlighting originally. So, I found one of its replacements: bat.

Brief Introduction

BAT Logo

On BAT's official GitHub page, it defines itself "a cat clone with wings". In my opinion, one is "syntax highlighting", and the other is "git integration".

Here are some of its important features:

  • Syntax highlighting
  • Git integration
  • Show non-printable characters
  • Automatic paging

BAT's syntax highlighting

BAT's git integration

BAT's non-printable characters showing

Installation

In ArchLinux, you can run:

1
sudo pacman -S bat

In Termux, you can run:

1
pkg install bat

In Ubuntu, you can run:

1
sudo apt install bat

Learn more on BAT's GitHub page.

Usage

1
2
3
4
5
6
7
8
9
# Display a single file:
bat <filename>

# Display multi files at once:
bat <filename1> <filename2> ...

# Show and highlight non-printable characters:
bat -A <filename> # or
bat --show-all <filename>

Learn more on BAT's GitHub page.

Configuration

You can use BAT's configuration file to customize your BAT.

To generate a default config file, run:

1
bat --generate-config-file

Here is an example:

1
2
3
4
5
# Set the theme
--theme="Dracula"

# Use C++ syntax for Arduino .ino files
--map-syntax "*.ino:C++"