Skip to content

🐱 bat

bat is a cat clone with syntax highlighting and Git integration.

🛠 Installation

bat is available in the reprepro repository.

sudo apt update
sudo apt install bat
sudo apt update
sudo apt install bat

On Debian and Ubuntu, the executable might be installed as batcat instead of bat due to a name conflict with another package. To use bat directly, you can create a symbolic link or an alias:

Symbolic Link

mkdir -p ~/.local/bin
ln -s /usr/bin/batcat ~/.local/bin/bat

Alias

echo "alias bat='batcat'" >> ~/.bashrc
source ~/.bashrc

⚙ Config

bat can be configured using a configuration file. You can find the default configuration directory by running bat --config-dir.

To set a theme permanently, you can export the BAT_THEME environment variable in your shell's configuration file (e.g., .bashrc or .zshrc).

Set Theme

export BAT_THEME="TwoDark"

You can also add new themes by creating a themes folder within bat's configuration directory and rebuilding the cache.

Add Themes

mkdir -p "$(bat --config-dir)/themes"
# Add theme files to the directory
bat cache --build

🐱 Catppuccin Theme

To install the Catppuccin theme for bat, follow these steps:

Install Catppuccin Theme

mkdir -p "$(bat --config-dir)/themes"
wget -P "$(bat --config-dir)/themes" https://github.com/catppuccin/bat/raw/main/themes/Catppuccin-mocha.tmTheme
bat cache --build

To use the Catppuccin theme, set BAT_THEME to Catppuccin-mocha:

Set Catppuccin Theme

export BAT_THEME="Catppuccin-mocha"

📝 Usage

To view a file:

bat filename.txt

To not show line numbers:

bat -p config.yaml

To show line numbers:

bat -n config.yaml

To concatenate multiple files:

bat file1.txt file2.txt

🔗 References