
Meet bat – A Better cat Command for Modern Linux Users
- 4 minsIntroduction
The classic cat
command has been a staple of Unix-like systems for decades, used to print file contents in a simple, no-frills way. But if you’re craving something more powerful, stylish, and developer-friendly, then meet bat
— a modern replacement with wings.
bat
isn’t just a pretty face; it adds line numbers, syntax highlighting, paging, and even Git integration to your file-viewing experience — all while being compatible with how you’d normally use cat
.
Why Use bat
?
- Syntax highlighting for dozens of programming languages
- Line numbers included by default
- Git-aware: highlights changed/added lines
- Paging support via
less
- Works as a drop-in replacement for
cat
in many cases
🗒️ Think of it as
cat
on steroids — ideal for developers and power users alike.
Installing bat
on Linux
bat
is available in the official repositories of most major Linux distributions.
🐧 Ubuntu / Debian
sudo apt install bat
✅ Note: On Ubuntu/Debian, the binary is called
batcat
. You’ll need to alias it manually if you want to call it asbat
.
🏹 Arch Linux
sudo pacman -S bat
🟥 Fedora / RHEL / CentOS
sudo dnf install bat
⚙️ Setting Up Alias (Ubuntu/Debian)
By default, on Debian-based distros, you’ll invoke the command using batcat
:
batcat filename.txt
Want to use bat
instead? Set up an alias:
alias bat="batcat"
To make it permanent, add it to your shell config file (~/.bashrc
, ~/.zshrc
, etc.):
echo "alias bat='batcat'" >> ~/.bashrc
source ~/.bashrc
Usage Examples
Just like cat
, you can view file contents:
batcat file.txt
Show Line Numbers Only
If you prefer minimal visuals:
batcat -n file.txt
💡 Force Syntax Highlighting
bat
auto-detects file types, but you can also manually set the language:
batcat -l python script.py
batcat -l c hello.c
View Multiple Files
You can pass multiple files, just like with cat
:
batcat file1.sh file2.sh
Pipe Output or Use with Other Commands
Works seamlessly with pipes and standard input:
echo "Hello, bat!" | batcat
Custom Themes and Configuration
bat
supports different syntax highlighting themes. To list available themes:
batcat --list-themes
Choose one by setting it via the config file or environment variable:
export BAT_THEME="TwoDark"
You can also create a bat
config at ~/.config/bat/config
.
Example:
--theme="TwoDark"
--style="numbers,changes,header"
Summary
batcat
is an awesome upgrade over the traditional cat
command, especially for developers and sysadmins who spend their day in the terminal. It keeps everything you love about cat
while adding modern capabilities that make reading code and config files a joy.
- Looks better ✅
- Reads better ✅
- Works with Git ✅
- Still just as fast ✅
If you’re customizing your CLI toolkit, bat
is a no-brainer.
More Tools Like bat
Love tools like bat
? Check out other modern replacements:
📘 Official Resources
Thanks for reading! If bat
earns a spot in your daily workflow, let me know what theme you’re rocking!
👍 🦇 🚀
— Guneycan Sanli