LinuxCommandLibrary

bat

Display file contents with syntax highlighting

TLDR

Pretty print the contents of one or more files to stdout

$ bat [path/to/file1 path/to/file2 ...]
copy

Concatenate several files into the target file
$ bat [path/to/file1 path/to/file2 ...] > [path/to/target_file]
copy

Remove decorations and disable paging (--style plain can be replaced with -p, or both options with -pp)
$ bat --style plain --pager never [path/to/file]
copy

Highlight a specific line or a range of lines with a different background color
$ bat [[-H|--highlight-line]] [10|5:10|:10|10:|10:+5] [path/to/file]
copy

Show non-printable characters like space, tab or newline
$ bat [[-A|--show-all]] [path/to/file]
copy

Remove all decorations except line numbers in the output
$ bat [[-n|--number]] [path/to/file]
copy

Syntax highlight a JSON file by explicitly setting the language
$ bat [[-l|--language]] json [path/to/file.json]
copy

Display all supported languages
$ bat [[-L|--list-languages]]
copy

SYNOPSIS

bat [options] [files...]

PARAMETERS

--help
    Show help message and exit.

-l, --language
    Explicitly set the language for syntax highlighting.

-n, --number
    Show line numbers.

-A, --plain
    Show plain text without syntax highlighting.

-p, --paging
    Specify when to use the pager: 'auto', 'always', or 'never'.

-r, --read-all
    Read all files even if the pager is not used.

-f, --force-colorization
    Force colorization even when output is piped.

-m, --map-syntax
    Specify a mapping from filenames to syntaxes.

-c, --cache
    Use 'clear' to clear the cache. Use 'config-dir' to show the configuration directory.

--theme
    Set the color theme for syntax highlighting.

--list-themes
    List available themes.

--style