BATCAT(1) | General Commands Manual | BATCAT(1) |
batcat - a cat(1) clone with syntax highlighting and Git integration.
batcat prints the syntax-highlighted content of a collection of FILEs to the terminal. If no FILE is specified, or when FILE is '-', it reads from standard input.
batcat supports a large number of programming and markup languages. It also communicates with git(1) to show modifications with respect to the git index. batcat automatically pipes its output through a pager (by default: less).
Whenever the output of batcat goes to a non-interactive terminal, i.e. when the output is piped into another process or into a file, batcat will act as a drop-in replacement for cat(1) and fall back to printing the plain file contents.
General remarks: Command-line options like '-l'/'--language' that take values can be specified as either '--language value', '--language=value', '-l value' or '-lvalue'.
-A, --show-all
--nonprintable-notation <notation>
Possible values:
-p, --plain
-l, --language <language>
-H, --highlight-line <N:M>...
--file-name <name>...
-d, --diff
--diff-context <N>...
--tabs <T>
--wrap <mode>
--terminal-width <width>
-n, --number
--color <when>
--italic-text <when>
--decorations <when>
-f, --force-colorization
--paging <when>
--pager <command>
Note: By default, if the pager is set to 'less' (and no command-line options are specified), 'bat' will pass the following command line options to the pager: '-R'/'--RAW-CONTROL-CHARS', '-F'/'--quit-if-one-screen' and '-X'/'--no-init'. The last option ('-X') is only used for 'less' versions older than 530. The '-R' option is needed to interpret ANSI colors correctly. The second option ('-F') instructs less to exit immediately if the output size is smaller than the vertical size of the terminal. This is convenient for small files because you do not have to press 'q' to quit the pager. The third option ('-X') is needed to fix a bug with the '--quit-if-one-screen' feature in old versions of 'less'. Unfortunately, it also breaks mouse-wheel support in 'less'. If you want to enable mouse-wheel scrolling on older versions of 'less', you can pass just '-R' (as in the example above, this will disable the quit-if-one-screen feature). For less 530 or newer, it should work out of the box.
-m, --map-syntax <glob-pattern:syntax-name>...
--theme <theme>
--list-themes
--style <style-components>
-r, --line-range <N:M>...
-L, --list-languages
-u, --unbuffered
-h, --help
-V, --version
<FILE>...
cache - Modify the syntax-definition and theme cache.
batcat can also be customized with a configuration file. The location of the file is dependent on your operating system. To get the default path for your system, call:
batcat --config-file
Alternatively, you can use the BAT_CONFIG_PATH environment variable to point batcat to a non-default location of the configuration file.
To generate a default configuration file, call:
batcat --generate-config-file
batcat supports Sublime Text .sublime-syntax language files, and can be customized to add additional languages to your local installation. To do this, add the .sublime-syntax language files to `$(batcat --config-dir)/syntaxes` and run `batcat cache --build`.
Example:
# Put new '.sublime-syntax' language definition files
# in this folder (or its subdirectories), for example:
git clone https://github.com/tellnobody1/sublime-purescript-syntax
# And then build the cache.
batcat cache --build
Once the cache is built, the new language will be visible in
`batcat --list-languages`.
If you ever want to remove the custom languages, you can clear the cache with
`batcat cache --clear`.
Similarly to custom languages, batcat supports Sublime Text .tmTheme themes. These can be installed to `$(batcat --config-dir)/themes`, and are added to the cache with `batcat cache --build`.
Much like less(1) does, batcat supports input preprocessors via the LESSOPEN and LESSCLOSE environment variables. In addition, batcat attempts to be as compatible with less's preprocessor implementation as possible.
To use the preprocessor, call:
batcat --lessopen
Alternatively, the preprocessor may be enabled by default by adding the '--lessopen' option to the configuration file.
To temporarily disable the preprocessor if it is enabled by default, call:
batcat --no-lessopen
For more information, see the "INPUT PREPROCESSOR" section of less(1).
For more information and up-to-date documentation, visit the
batcat repo:
https://github.com/sharkdp/bat