How to Replace `cat` with `bat` for Colorful Code in Windows Terminal

How to Replace `cat` with `bat` for Colorful Code in Windows Terminal

Make Your Terminal Colorful: Replace `cat` with `bat` in Windows Terminal

Want to make your terminal output colorful, like VSCode? Here’s a quick guide on how to install bat and use it as an alias for cat in your Windows Terminal!


Step 1: Install `bat`

First, install bat from the official GitHub repository. Open your Windows Terminal and run the following command:

winget install sharkdp.bat

You can find more installation details on the official GitHub page.


Step 2: Open Your Profile in Notepad

In PowerShell, type the following command to open your profile script in Notepad:

notepad $profile

If prompted, choose to create a new file.


Step 3: Set Alias for `cat` to `bat`

Add the following line in the Notepad file to set cat as an alias for bat:

Set-Alias -Name cat -Value bat

Save and close the file after adding this line.


Step 4: Restart PowerShell

Restart your PowerShell to apply the changes. Now, when you use cat in the terminal, it will automatically use bat to display file content with syntax highlighting and other improvements!


Enjoy the Colorful Output!

You’re all set! Using cat in your terminal will now give you a colorful, VSCode-like display for your code files. Enjoy a better coding experience right in your terminal!

Subscribe - Thapa Technical