• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

Bat – A Cat Clone with Syntax Highlighting and Git Integration

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
67
VIEWS
Share on FacebookShare on Twitter

Contents

  1. How to Install Bat (A cat clone) in Linux
    1. Summary

Bat is a cat command clone with advance syntax highlighting for a large number of programming and markup languages and it also comes with Git integration to show file modifications. Its other features include automatic paging, file concatenation, themes for syntax highlighting and various styles for presenting output.

Read Also: ccat – Show ‘cat Command’ Output with Syntax Highlighting or Colorizing

In addition, you can also add new syntaxes / language definitions, themes and set a custom pager. In this article, we will show how to install and use a Bat (cat clone) in Linux.

Read Also: How to Use ‘cat’ and ‘tac’ Commands with Examples in Linux

How to Install Bat (A cat clone) in Linux

On Debian and other Debian-based Linux distributions, you can download the latest .deb package from the release page or use the following the wget command to download and install it as shown.

$ wget https://github.com/sharkdp/bat/releases/download/v0.8.0/bat_0.8.0_amd64.deb
$ sudo dpkg -i bat_0.8.0_amd64.deb

On Arch Linux, you can install it from the Community repository as shown.

$ sudo pacman -S bat

After installing bat, simply run it in the same way you normally run cat command, for example, the following command will display the specified file content with syntax highlighting.

$ bat bin/bashscripts/sysadmin/topprocs.sh
Bat – A Cat Clone with Syntax Highlighting and Git Integration

View a File with Syntax Highlighting

To display multiple files at ones, use the following command.

$ bat domains.txt hosts
Bat – A Cat Clone with Syntax Highlighting and Git Integration

Display Multiple Files Content

You can only print a specified range of lines (for example print lines 13 to 24 only) for a file or each file, using the --line-range switch as shown.

$ bat --line-range 13:24 bin/bashscripts/sysadmin/topprocs.sh
Bat – A Cat Clone with Syntax Highlighting and Git Integration

Print Specified Range of Lines

To show all supported language names and file extensions, use the –list-languages option.

$ bat --list-languages
Bat – A Cat Clone with Syntax Highlighting and Git Integration

List Supported Languages for Syntax Highlighting

Then explicitly set a language for syntax highlighting using the -l switch.

$ bat -l Python httpie/setup.py
Bat – A Cat Clone with Syntax Highlighting and Git Integration

Set Language for Syntax Highlighting

You can also read from stdin as in this example.

$ ls -l | bat
Bat – A Cat Clone with Syntax Highlighting and Git Integration

Read from Stdin Output

To see a list of available themes for syntax highlighting, use the --list-themes option.

$ bat --list-themes
Bat – A Cat Clone with Syntax Highlighting and Git Integration

List Themes for Syntax Highlighting

After you have picked a theme to use, enable it with the --theme option.

$ bat --theme=Github

Note that these settings will be lost after a reboot, to make the changes permanent, export the BAT_THEME environment variable in the file ~/.bashrc (user specific) or /etc/bash.bashrc (system-wide) by adding the following line in it.

export BAT_THEME="Github"

To only show line numbers without any other decorations, use the -n switch.

$ bat -n domains.txt hosts

Bat uses “less” as the default pager. However, you can specify when to use the pager, with the --paging and the possible values include *auto*, never and always.
$ bat –paging always

In addition, you can define the pager using the PAGER or BAT_PAGER (this takes precedence) environment variables, in a similar fashion as the BAT_THEME env variable, as explained above. Setting these variables with empty values disables the pager.

For more information on how to use or customize bat, type man bat or go to its Github Repository: https://github.com/sharkdp/bat.

Summary

Bat is a user-friendly cat clone with syntax highlighting and git integration. Share your thoughts about it, with us via the feedback form below. If you have come across any similar CLI utilities out there, let us know as well.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

Create Multiple IP Addresses to One Single Network Interface

Next Post

DEBUGFS Command – Show File Creation Times in Linux

Next Post

DEBUGFS Command – Show File Creation Times in Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet