2 <img src="doc/logo-header.svg" alt="bat - a cat clone with wings"><br>
3 <a href="https://travis-ci.org/sharkdp/bat"><img src="https://travis-ci.org/sharkdp/bat.svg?branch=master" alt="Build Status"></a>
4 <img src="https://img.shields.io/crates/l/bat.svg" alt="license">
5 <a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br>
6 A <i>cat(1)</i> clone with syntax highlighting and Git integration.
10 <a href="#syntax-highlighting">Key Features</a> •
11 <a href="#how-to-use">How To Use</a> •
12 <a href="#installation">Installation</a> •
13 <a href="#customization">Customization</a> •
14 <a href="#project-goals-and-alternatives">Project goals, alternatives</a>
17### Syntax highlighting
19`bat` supports syntax highlighting for a large number of programming and markup
22
26`bat` communicates with `git` to show modifications with respect to the index
29
33`bat` can pipe its own output to `less` if the output is too large for one screen.
37Oh.. you can also use it to concatenate files :wink:. Whenever
38`bat` detects a non-interactive terminal, it will fall back to printing
39the plain file contents.
43Display a single file on the terminal
49Display multiple files at once
55Read from stdin, explicitly specify the language
58> yaml2json .travis.yml | json_pp | bat -l json
62> curl -s https://raw.githubusercontent.com/sharkdp/bat/master/src/main.rs | bat -l rs
65As a replacement for `cat`:
68bat > note.md # quickly create a new file
70bat header.md content.md footer.md > document.md
72bat -n main.rs # show line numbers (only)
74bat f - g # output 'f', then stdin, then 'g'.
80*... and other Debian-based Linux distributions.*
82Download the latest `.deb` package from the [release page](https://github.com/sharkdp/bat/releases)
85sudo dpkg -i bat_0.6.0_amd64.deb # adapt version number and architecture
90You can install [the `bat` package](https://www.archlinux.org/packages/community/x86_64/bat/)
91from the official sources:
99You can install `bat` via xbps-install:
106You can install a precompiled [`bat` package](https://www.freshports.org/textproc/bat) with pkg:
112or build it on your own from the FreeBSD ports:
115cd /usr/ports/textproc/bat
121You can install `bat` with [Homebrew](http://braumeister.org/formula/bat):
129Check out the [Release page](https://github.com/sharkdp/bat/releases) for
130prebuilt versions of `bat` for many different architectures.
134If you want to build `bat` from source, you need Rust 1.26 or
135higher. You can then use `cargo` to build everything:
141On macOS, you might have to install `cmake` (`brew install cmake`) in order for
142some dependencies to be built.
146### Highlighting theme
148Use `bat --list-themes` to get a list of all available themes for syntax
149highlighting. To select the `TwoDark` theme, call `bat` with the
150`--theme=TwoDark` option or set the `BAT_THEME` environment variable to
151`TwoDark`. Use `export BAT_THEME="TwoDark"` in your shells startup file to
152make the change permanent.
156You can use the `--style` option to control the appearance of `bat`s output.
157You can use `--style=numbers,changes`, for example, to show only Git changes
158and line numbers but no grid and no file header.
160### Adding new syntaxes / language definitions
162`bat` uses the excellent [`syntect`](https://github.com/trishume/syntect/)
163library for syntax highlighting. `syntect` can read any
164[Sublime Text `.sublime-syntax` file](https://www.sublimetext.com/docs/3/syntax.html)
165and theme. To add new syntax definitions, do the following.
167Create a folder with syntax definition files:
170BAT_CONFIG_DIR="$(bat cache --config-dir)"
172mkdir -p "$BAT_CONFIG_DIR/syntaxes"
173cd "$BAT_CONFIG_DIR/syntaxes"
175# Put new '.sublime-syntax' language definition files
176# in this folder (or its subdirectories), for example:
177git clone https://github.com/tellnobody1/sublime-purescript-syntax
180Now use the following command to parse these files into a binary cache:
186Finally, use `bat --list-languages` to check if the new languages are available.
188If you ever want to go back to the default settings, call:
196This works very similar to how we add new syntax definitions.
198First, create a folder with the new syntax highlighting themes:
200BAT_CONFIG_DIR="$(bat cache --config-dir)"
202mkdir -p "$BAT_CONFIG_DIR/themes"
203cd "$BAT_CONFIG_DIR/themes"
205# Download a theme in '.tmTheme' format, for example:
206git clone https://github.com/greggb/sublime-snazzy
208# Update the binary cache
212Finally, use `bat --list-themes` to check if the new themes are available.
214### Using a different pager
216`bat` uses the pager that is specified in the `PAGER` environment variable. If this variable is not
217set, `less` is used by default. If you want to use a different pager, you can either modify the
218`PAGER` variable or set the `BAT_PAGER` environment variable to override what is specified in
219`PAGER`. If you want to pass command-line arguments to the pager, you need to create a small shell
220script as a wrapper, for example:
225less --tabs 4 -RF "$@"
230### Terminals & colors
232`bat` handles terminals *with* and *without* truecolor support. However, the colors in the syntax
233highlighting themes are not optimized for 8-bit colors and it is therefore strongly recommended
234that you use a terminal with 24-bit truecolor support (`terminator`, `konsole`, `iTerm2`, ...).
235See [this article](https://gist.github.com/XVilka/8346728) for more details and a full list of
236terminals with truecolor support.
238Make sure that your truecolor terminal sets the `COLORTERM` variable to either `truecolor` or
239`24bit`. Otherwise, `bat` will not be able to determine whether or not 24-bit escape sequences
240are supported (and fall back to 8-bit colors).
245# Recursive clone to retrieve all submodules
246git clone --recursive https://github.com/sharkdp/bat
248# Build (debug version)
252# Run unit tests and integration tests
255# Install (release version)
258# Build a bat binary with modified syntaxes and themes
263## Project goals and alternatives
265`bat` tries to achieve the following goals:
267- Provide beautiful, advanced syntax highlighting
268- Integrate with Git to show file modifications
269- Be a drop-in replacement for (POSIX) `cat`
270- Offer a user-friendly command-line interface
272There are a lot of alternatives, if you are looking for similar programs. See
273[this document](doc/alternatives.md) for a comparison.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list