bat¶
bat is a cat clone with syntax highlighting and Git integration.
Installation¶
bat is available in the reprepro repository.
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:
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).
You can also add new themes by creating a themes folder within bat's configuration directory and rebuilding the cache.
Add Themes
Catppuccin Theme¶
To install the Catppuccin theme for bat, follow these steps:
Install Catppuccin Theme
To use the Catppuccin theme, set BAT_THEME to Catppuccin-mocha:
Usage¶
To view a file:
To not show line numbers:
To show line numbers:
To concatenate multiple files:
Troubleshooting¶
When using bat and pressing Tab
This error indicates that bash-completion is not correctly set up or sourced. To resolve this, ensure the following:
-
Install
bash-completion: Make sure thebash-completionpackage is installed on your system. -
Source
bash_completion.sh: Verify that/etc/profile.d/bash_completion.shis sourced in your shell's startup files (e.g.,.bashrcor.profile). This file sets up thebash-completionenvironment. -
Run
batcompletion command: Ensure that thebatcompletion script is loaded. Add the following line to your~/.bashrcfile:After adding, reload your shell configuration: