on fcecd97 help sign in
bat/README.md
144 lines 3.2 kB history raw
1# bat
3[![Build Status](https://travis-ci.org/sharkdp/bat.svg?branch=master)](https://travis-ci.org/sharkdp/bat)
4[![Version info](https://img.shields.io/crates/v/bat.svg)](https://crates.io/crates/bat)
6A *cat(1)* clone with syntax highlighting and Git integration.
8## Features
10### Syntax highlighting
12`bat` supports syntax highlighting for a large number of programming and markup
13languages:
15![Syntax highlighting example](https://imgur.com/rGsdnDe.png)
17### Git integration
19`bat` communicates with `git` to show modifications with respect to the index
20(see left side bar):
22![Git integration example](https://i.imgur.com/2lSW4RE.png)
24### Automatic paging
26`bat` can pipe its own output to `less` if the output is too large for one screen.
28### File concatenation
30Oh.. you can also use it to concatenate files :wink:. Whenever
31`bat` detects a non-interactive terminal, it will fall back to printing
32the plain file contents.
34## Usage
36Display a single file on the terminal
38``` bash
39> bat README.md
40```
42Display multiple files at once
44``` bash
45> bat src/*.rs
46```
48Explicitly specify the language
50``` bash
51> yaml2json .travis.yml | json_pp | bat -l json
52```
54``` bash
55> curl -s https://raw.githubusercontent.com/sharkdp/bat/master/src/main.rs | bat -l rs
56```
59## Installation
61### From binaries
63Check out the [Release page](https://github.com/sharkdp/bat/releases) for
64binary builds and Debian packages.
66#### On Arch Linux
68You can install [the AUR package](https://aur.archlinux.org/packages/bat/)
69via yaourt, or manually:
71```bash
72git clone https://aur.archlinux.org/bat.git
73cd bat
74makepkg -si
75```
77#### On macOS
79You can install `bat` with [Homebrew](http://braumeister.org/formula/bat):
81``` bash
82brew install bat
83```
85### From source
87If you want to build to compile `bat` from source, you need Rust 1.24 or
88higher. You can then use `cargo` to build everything:
90``` bash
91cargo install bat
92```
94On macOS, you might have to install `cmake` (`brew install cmake`) in order for
95some dependencies to be built.
97## Customization
99`bat` uses the excellent [`syntect`](https://github.com/trishume/syntect/)
100library for syntax highlighting. `syntect` can read any
101[Sublime Text `.sublime-syntax` file](https://www.sublimetext.com/docs/3/syntax.html)
102and theme.
104To build your own language-set and theme, follow these steps:
106Create a folder with a syntax highlighting theme:
108``` bash
109BAT_CONFIG_DIR="$(bat cache --config-dir)"
111mkdir -p "$BAT_CONFIG_DIR/themes"
112cd "$BAT_CONFIG_DIR/themes"
114# Download a theme, for example:
115git clone https://github.com/jonschlinkert/sublime-monokai-extended
117# Create a 'Default.tmTheme' link
118ln -s "sublime-monokai-extended/Monokai Extended.tmTheme" Default.tmTheme
119```
121Create a folder with language definition files:
123``` bash
124mkdir -p "$BAT_CONFIG_DIR/syntax"
125cd "$BAT_CONFIG_DIR/syntax"
127# Download some language definition files, for example:
128git clone https://github.com/sublimehq/Packages/
129rm -rf Packages/Markdown
130git clone https://github.com/jonschlinkert/sublime-markdown-extended
131```
133Finally, use the following command to parse all these files into a binary
134cache:
136``` bash
137bat cache --init
138```
140If you ever want to go back to the default settings, call:
142``` bash
143bat cache --clear
144```