Bat: How to Use a Theme

Updated

Learn how to use a syntax highlighting theme with bat

Bat: How to Use a Theme

Before we start, make sure you have bat installed on your computer and a code file ready in a folder. If you don't have bat yet, you can install it with Homebrew:

brew install bat

First, open your terminal and navigate to the folder that has your file. To see every theme that bat comes with, run this command:

bat --list-themes

When you pipe the list into another command, bat prints just the theme names. To use one of them for a single command, add the --theme flag:

bat --theme="Dracula" filename

Just remember to replace Dracula with the theme you picked and filename with your actual file name. If a theme name has spaces, like Solarized (dark), keep it inside the quotes.

To make a theme the default, so you don't have to type the flag every time, add this line to your ~/.zshrc file:

export BAT_THEME="Dracula"

Then reload your shell, and bat filename will use the theme every time:

source ~/.zshrc
undefined

If you'd rather keep it in bat's config file, run bat --config-file to see where it lives, and add --theme="Dracula" on its own line.