1BAT(1) General Commands Manual BAT(1)
2
3
4
6 bat - a cat(1) clone with syntax highlighting and Git integration.
7
9 bat [OPTIONS] [FILE]...
10
11 bat cache [CACHE-OPTIONS] [--build|--clear]
12
14 bat prints the syntax-highlighted content of a collection of FILEs to
15 the terminal. If no FILE is specified, or when FILE is '-', it reads
16 from standard input.
17
18 bat supports a large number of programming and markup languages. It
19 also communicates with git(1) to show modifications with respect to the
20 git index. bat automatically pipes its output through a pager (by de‐
21 fault: less).
22
23 Whenever the output of bat goes to a non-interactive terminal, i.e.
24 when the output is piped into another process or into a file, bat will
25 act as a drop-in replacement for cat(1) and fall back to printing the
26 plain file contents.
27
28
30 General remarks: Command-line options like '-l'/'--language' that take
31 values can be specified as either '--language value', '--lan‐
32 guage=value', '-l value' or '-lvalue'.
33
34 -A, --show-all
35
36 Show non-printable characters like space, tab or newline. Use
37 '--tabs' to control the width of the tab-placeholders.
38
39 -p, --plain
40
41 Only show plain style, no decorations. This is an alias for
42 '--style=plain'. When '-p' is used twice ('-pp'), it also dis‐
43 ables automatic paging (alias for '--style=plain
44 --pager=never').
45
46 -l, --language <language>
47
48 Explicitly set the language for syntax highlighting. The lan‐
49 guage can be specified as a name (like 'C++' or 'LaTeX') or pos‐
50 sible file extension (like 'cpp', 'hpp' or 'md'). Use
51 '--list-languages' to show all supported language names and file
52 extensions.
53
54 -H, --highlight-line <N:M>...
55
56 Highlight the specified line ranges with a different background
57 color For example:
58
59 --highlight-line 40
60 highlights line 40
61
62 --highlight-line 30:40
63 highlights lines 30 to 40
64
65 --highlight-line :40
66 highlights lines 1 to 40
67
68 --highlight-line 40:
69 highlights lines 40 to the end of the file
70
71 --tabs <T>
72
73 Set the tab width to T spaces. Use a width of 0 to pass tabs
74 through directly
75
76 --wrap <mode>
77
78 Specify the text-wrapping mode (*auto*, never, character). The
79 '--terminal-width' option can be used in addition to control the
80 output width.
81
82 --terminal-width <width>
83
84 Explicitly set the width of the terminal instead of determining
85 it automatically. If prefixed with '+' or '-', the value will be
86 treated as an offset to the actual terminal width. See also:
87 '--wrap'.
88
89 -n, --number
90
91 Only show line numbers, no other decorations. This is an alias
92 for '--style=numbers'
93
94 --color <when>
95
96 Specify when to use colored output. The automatic mode only en‐
97 ables colors if an interactive terminal is detected. Possible
98 values: *auto*, never, always.
99
100 --italic-text <when>
101
102 Specify when to use ANSI sequences for italic text in the out‐
103 put. Possible values: always, *never*.
104
105 --decorations <when>
106
107 Specify when to use the decorations that have been specified via
108 '--style'. The automatic mode only enables decorations if an in‐
109 teractive terminal is detected. Possible values: *auto*, never,
110 always.
111
112 -f, --force-colorization
113
114 Alias for '--decorations=always --color=always'. This is useful
115 if the output of bat is piped to another program, but you want
116 to keep the colorization/decorations.
117
118 --paging <when>
119
120 Specify when to use the pager. To disable the pager, use '--pag‐
121 ing=never' or its alias, -P. To disable the pager permanently,
122 set BAT_PAGER to an empty string. To control which pager is
123 used, see the '--pager' option. Possible values: *auto*, never,
124 always.
125
126 --pager <command>
127
128 Determine which pager is used. This option will override the
129 PAGER and BAT_PAGER environment variables. The default pager is
130 'less'. To control when the pager is used, see the '--paging'
131 option. Example: '--pager "less -RF"'.
132
133 -m, --map-syntax <glob-pattern:syntax-name>...
134
135 Map a glob pattern to an existing syntax name. The glob pattern
136 is matched on the full path and the filename. For example, to
137 highlight *.build files with the Python syntax, use -m
138 '*.build:Python'. To highlight files named '.myignore' with the
139 Git Ignore syntax, use -m '.myignore:Git Ignore'.
140
141 --theme <theme>
142
143 Set the theme for syntax highlighting. Use '--list-themes' to
144 see all available themes. To set a default theme, add the
145 '--theme="..."' option to the configuration file or export the
146 BAT_THEME environment variable (e.g.: export BAT_THEME="...").
147
148 --list-themes
149
150 Display a list of supported themes for syntax highlighting.
151
152 --style <style-components>
153
154 Configure which elements (line numbers, file headers, grid bor‐
155 ders, Git modifications, ..) to display in addition to the file
156 contents. The argument is a comma-separated list of components
157 to display (e.g. 'numbers,changes,grid') or a pre-defined style
158 ('full'). To set a default style, add the '--style=".."' option
159 to the configuration file or export the BAT_STYLE environment
160 variable (e.g.: export BAT_STYLE=".."). Possible values: *auto*,
161 full, plain, changes, header, grid, rule, numbers, snip.
162
163 -r, --line-range <N:M>...
164
165 Only print the specified range of lines for each file. For exam‐
166 ple:
167
168 --line-range 30:40
169 prints lines 30 to 40
170
171 --line-range :40
172 prints lines 1 to 40
173
174 --line-range 40:
175 prints lines 40 to the end of the file
176
177 -L, --list-languages
178
179 Display a list of supported languages for syntax highlighting.
180
181 -u, --unbuffered
182
183 This option exists for POSIX-compliance reasons ('u' is for 'un‐
184 buffered'). The output is always unbuffered - this option is
185 simply ignored.
186
187 -h, --help
188
189 Print this help message.
190
191 -V, --version
192
193 Show version information.
194
196 <FILE>...
197
198 Files to print and concatenate. Use a dash ('-') or no argument
199 at all to read from standard input.
200
202 cache - Modify the syntax-definition and theme cache.
203
205 bat can also be customized with a configuration file. The location of
206 the file is dependent on your operating system. To get the default path
207 for your system, call:
208
209 bat --config-file
210
211 Alternatively, you can use the BAT_CONFIG_PATH environment variable to
212 point bat to a non-default location of the configuration file.
213
215 bat supports Sublime Text .sublime-syntax language files, and can be
216 customized to add additional languages to your local installation. To
217 do this, add the .sublime-syntax language files to `$(bat --config-
218 dir)/syntaxes` and run `bat cache --build`.
219
220 Example:
221
222 mkdir -p "$(bat --config-dir)/syntaxes"
223 cd "$(bat --config-dir)/syntaxes"
224
225 # Put new '.sublime-syntax' language definition files
226 # in this folder (or its subdirectories), for example:
227 git clone https://github.com/tellnobody1/sublime-purescript-syntax
228
229 # And then build the cache.
230 bat cache --build
231
232 Once the cache is built, the new language will be visible in `bat
233 --list-languages`.
234 If you ever want to remove the custom languages, you can clear the
235 cache with `bat cache --clear`.
236
237
239 Similarly to custom languages, bat supports Sublime Text .tmTheme
240 themes. These can be installed to `$(bat --config-dir)/themes`, and
241 are added to the cache with `bat cache --build`.
242
244 For more information and up-to-date documentation, visit the bat repo:
245 https://github.com/sharkdp/bat
246
247
248
249 BAT(1)