aboutsummaryrefslogtreecommitdiff
path: root/bat/bat.1
blob: 7c939ad8b886c1cdd57fdbd62818c99db3653ac1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
.TH BAT "1"
.SH NAME
bat \- a cat(1) clone with syntax highlighting and Git integration.
.SH "USAGE"
.IP "bat [OPTIONS] [FILE]..."
.IP "bat cache [CACHE-OPTIONS] [--build|--clear]
.SH DESCRIPTION
bat 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.

bat supports a large number of programming and markup languages.
It also communicates with git(1) to show modifications with respect to the git index.
bat automatically pipes its output through a pager (by default: less).

Whenever the output of bat goes to a non-interactive terminal, i.e. when the
output is piped into another process or into a file, bat will act as a drop-in
replacement for cat(1) and fall back to printing the plain file contents.

.SH "OPTIONS"
General remarks: Command-line options like '-l'/'--language' that take values can be specified as
either '--language value', '--language=value', '-l value' or '-lvalue'.
.HP
\fB\-A\fR, \fB\-\-show\-all\fR
.IP
Show non\-printable characters like space, tab or newline. Use '\-\-tabs' to
control the width of the tab\-placeholders.
.HP
\fB\-p\fR, \fB\-\-plain\fR
.IP
Only show plain style, no decorations. This is an alias for
\&'\-\-style=plain'. When '\-p' is used twice ('\-pp'), it also disables
automatic paging (alias for '\-\-style=plain \fB\-\-paging\fR=\fI\,never\/\fR').
.HP
\fB\-l\fR, \fB\-\-language\fR <language>
.IP
Explicitly set the language for syntax highlighting. The language can be
specified as a name (like 'C++' or 'LaTeX') or possible file extension
(like 'cpp', 'hpp' or 'md'). Use '\-\-list\-languages' to show all supported
language names and file extensions.
.HP
\fB\-H\fR, \fB\-\-highlight\-line\fR <N:M>...
.IP
Highlight the specified line ranges with a different background color. For example:
.RS
.IP "\-\-highlight\-line 40"
highlights line 40
.IP "\-\-highlight\-line 30:40"
highlights lines 30 to 40
.IP "\-\-highlight\-line :40"
highlights lines 1 to 40
.IP "\-\-highlight\-line 40:"
highlights lines 40 to the end of the file
.IP "\-\-highlight\-line 30:+10"
highlights lines 30 to 40
.RE
.HP
\fB\-\-file\-name\fR <name>...
.IP
Specify the name to display for a file. Useful when piping data to bat from STDIN when bat does not otherwise know the filename. Note that the provided file name is also used for syntax detection.
.HP
\fB\-d\fR, \fB\-\-diff\fR
.IP
Only show lines that have been added/removed/modified with respect to the Git index. Use '\-\-diff\-context=N' to control how much context you want to see.
.HP
\fB\-\-diff\-context\fR <N>...
.IP
Include N lines of context around added/removed/modified lines when using '\-\-diff'.
.HP
\fB\-\-tabs\fR <T>
.IP
Set the tab width to T spaces. Use a width of 0 to pass tabs through directly
.HP
\fB\-\-wrap\fR <mode>
.IP
Specify the text\-wrapping mode (*auto*, never, character). The '\-\-terminal\-width' option
can be used in addition to control the output width.
.HP
\fB\-\-terminal\-width\fR <width>
.IP
Explicitly set the width of the terminal instead of determining it automatically. If
prefixed with '+' or '\-', the value will be treated as an offset to the actual terminal
width. See also: '\-\-wrap'.
.HP
\fB\-n\fR, \fB\-\-number\fR
.IP
Only show line numbers, no other decorations. This is an alias for '\-\-style=numbers'
.HP
\fB\-\-color\fR <when>
.IP
Specify when to use colored output. The automatic mode only enables colors if an
interactive terminal is detected. Possible values: *auto*, never, always.
.HP
\fB\-\-italic\-text\fR <when>
.IP
Specify when to use ANSI sequences for italic text in the output. Possible values:
always, *never*.
.HP
\fB\-\-decorations\fR <when>
.IP
Specify when to use the decorations that have been specified via '\-\-style'. The
automatic mode only enables decorations if an interactive terminal is detected. Possible
values: *auto*, never, always.
.HP
\fB\-f\fR, \fB\-\-force\-colorization\fR
.IP
Alias for '--decorations=always --color=always'. This is useful \
if the output of bat is piped to another program, but you want \
to keep the colorization/decorations.
.HP
\fB\-\-paging\fR <when>
.IP
Specify when to use the pager. To disable the pager, use \&'\-\-paging=never' or its alias,
\fB-P\fR. To disable the pager permanently, set BAT_PAGER to an empty string. To control
which pager is used, see the '\-\-pager' option. Possible values: *auto*, never, always.
.HP
\fB\-\-pager\fR <command>
.IP
Determine which pager is used. This option will override the PAGER and BAT_PAGER
environment variables. The default pager is 'less'. To control when the pager is used, see
the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'.

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.
.HP
\fB\-m\fR, \fB\-\-map\-syntax\fR <glob-pattern:syntax-name>...
.IP
Map a glob pattern to an existing syntax name. The glob pattern is matched on the full
path and the filename. For example, to highlight *.build files with the Python syntax,
use -m '*.build:Python'. To highlight files named '.myignore' with the Git Ignore
syntax, use -m '.myignore:Git Ignore'.
Note that the right-hand side is the *name* of the syntax, not a file extension.
.HP
\fB\-\-theme\fR <theme>
.IP
Set the theme for syntax highlighting. Use '\-\-list\-themes' to see all available themes.
To set a default theme, add the '\-\-theme="..."' option to the configuration file or
export the BAT_THEME environment variable (e.g.: export BAT_THEME="...").
.HP
\fB\-\-list\-themes\fR
.IP
Display a list of supported themes for syntax highlighting.
.HP
\fB\-\-style\fR <style\-components>
.IP
Configure which elements (line numbers, file headers, grid borders, Git modifications,
\&..) to display in addition to the file contents. The argument is a comma\-separated list
of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full').
To set a default style, add the '\-\-style=".."' option to the configuration file or
export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible
values: *default*, full, auto, plain, changes, header, header-filename, header-filesize, grid,
rule, numbers, snip.
.HP
\fB\-r\fR, \fB\-\-line\-range\fR <N:M>...
.IP
Only print the specified range of lines for each file. For example:
.RS
.IP "\-\-line\-range 30:40"
prints lines 30 to 40
.IP "\-\-line\-range :40"
prints lines 1 to 40
.IP "\-\-line\-range 40:"
prints lines 40 to the end of the file
.IP "\-\-line\-range 30:+10"
prints lines 30 to 40
.RE
.HP
\fB\-L\fR, \fB\-\-list\-languages\fR
.IP
Display a list of supported languages for syntax highlighting.
.HP
\fB\-u\fR, \fB\-\-unbuffered\fR
.IP
This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered'). The output is
always unbuffered \- this option is simply ignored.
.HP
\fB\-h\fR, \fB\-\-help\fR
.IP
Print this help message.
.HP
\fB\-V\fR, \fB\-\-version\fR
.IP
Show version information.
.SH "POSITIONAL ARGUMENTS"
.HP
\fB<FILE>...\fR
.IP
Files to print and concatenate. Use a dash ('\-') or no argument at all to read from
standard input.
.SH "SUBCOMMANDS"
.HP
\fBcache\fR - Modify the syntax\-definition and theme cache.
.SH "FILES"
bat 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:

\fBbat --config-file\fR

Alternatively, you can use the BAT_CONFIG_PATH environment variable to point bat to a non-default
location of the configuration file.

To generate a default configuration file, call:

\fBbat --generate-config-file\fR
.SH "ADDING CUSTOM LANGUAGES"
bat supports Sublime Text \fB.sublime-syntax\fR language files, and can be
customized to add additional languages to your local installation. To do this, add the \fB.sublime-syntax\fR language
files to `\fB$(bat --config-dir)/syntaxes\fR` and run `\fBbat cache --build\fR`.

\fBExample:\fR

.RS 0.5i
mkdir -p "$(bat --config-dir)/syntaxes"
.br
cd "$(bat --config-dir)/syntaxes"

# Put new '.sublime-syntax' language definition files
.br
# in this folder (or its subdirectories), for example:
.br
git clone https://github.com/tellnobody1/sublime-purescript-syntax

# And then build the cache.
.br
bat cache --build
.RE

Once the cache is built, the new language will be visible in `\fBbat --list-languages\fR`.
.br
If you ever want to remove the custom languages, you can clear the cache with `\fBbat cache --clear\fR`.

.SH "ADDING CUSTOM THEMES"
Similarly to custom languages, bat supports Sublime Text \fB.tmTheme\fR themes.
These can be installed to `\fB$(bat --config-dir)/themes\fR`, and are added to the cache with
`\fBbat cache --build`.
.SH "MORE INFORMATION"

For more information and up-to-date documentation, visit the bat repo:
.br
\fBhttps://github.com/sharkdp/bat\fR