on master help sign in
Add new theme: base16-256

Bat already has a base16 theme. The new base16-256 theme is for users of base16-shell, who configure their terminal with a 256-color variant of a base16 theme. These variants put some of the base16 colors in elsewhere in the 256-color table to avoid clobbering bright color slots (ansi codes 8 to 15) with colors that don't respect the ordinary meaning of that slot (e.g. bright green in ordinary base16 is not green). For more details, see https://github.com/chriskempson/base16-shell

commitf9d5e81f0e72a130ccbe466c82ee1a0acb919c3d authorMitchell Kember <mk12360@gmail.com> dateSun 19 Jul 2020, 16:49 (6 years ago) parent00d1267
5 files changed+586−6
CHANGELOG.md+1 README.md+24−3 assets/themes/base16-256.tmTheme+551 assets/themes/base16.tmTheme+9−2 src/terminal.rs+1−1
CHANGELOG.md+1
@@ -20,6 +20,7 @@
2020## New themes
2121
2222- Gruvbox, see #1069 (@kyleondy)
23+- base16-256 for [base16-shell](https://github.com/chriskempson/base16-shell) users, see #1111 (@mk12)
2324
2425## `bat` as a library
2526
README.md+24−3
@@ -354,6 +354,26 @@ light background, some themes like `GitHub` or `OneHalfLight` will work better f
354354You can also use a custom theme by following the
355355['Adding new themes' section below](https://github.com/sharkdp/bat#adding-new-themes).
356356
357+### 8-bit themes
358+
359+`bat` has four themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors),
360+even when truecolor support is available:
361+
362+- `ansi-dark` looks decent on any terminal with a dark background. It uses 3-bit colors: black, red,
363+ green, yellow, blue, magenta, cyan, and white.
364+- `ansi-light` is like `ansi-dark`, but for terminals with a light background.
365+- `base16` is designed for [base16](https://github.com/chriskempson/base16) terminal themes. It uses
366+ 4-bit colors (3-bit colors plus bright variants) in accordance with the
367+ [base16 styling guidelines](https://github.com/chriskempson/base16/blob/master/styling.md).
368+- `base16-256` is designed for [base16-shell](https://github.com/chriskempson/base16-shell).
369+ It replaces certain bright colors with 8-bit colors from 16 to 21. **Do not** use this simply
370+ because you have a 256-color terminal but are not using base16-shell.
371+
372+Although these themes are more restricted, they have two advantages over truecolor themes:
373+
374+- They harmonize better with other terminal software using 3-bit or 4-bit colors.
375+- When you change your terminal theme, `bat` output already on the screen will update to match.
376+
357377### Output style
358378
359379You can use the `--style` option to control the appearance of `bat`s output.
@@ -554,9 +574,10 @@ bat() {
554574
555575### Terminals & colors
556576
557−`bat` handles terminals *with* and *without* truecolor support. However, the colors in the syntax
558−highlighting themes are not optimized for 8-bit colors and it is therefore strongly recommended
559−that you use a terminal with 24-bit truecolor support (`terminator`, `konsole`, `iTerm2`, ...).
577+`bat` handles terminals *with* and *without* truecolor support. However, the colors in most syntax
578+highlighting themes are not optimized for 8-bit colors. It is therefore strongly recommended
579+that you use a terminal with 24-bit truecolor support (`terminator`, `konsole`, `iTerm2`, ...),
580+or use one of the basic [8-bit themes](#8-bit-themes) designed for a restricted set of colors.
560581See [this article](https://gist.github.com/XVilka/8346728) for more details and a full list of
561582terminals with truecolor support.
562583
assets/themes/base16-256.tmThemenew file+551
@@ -0,0 +1,551 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+<plist version="1.0">
4+ <dict>
5+ <!--
6+ Most base16 users should use the base16 theme. This theme, base16-256,
7+ is for users who configure their terminal with a 256-color variant of a
8+ base16 theme, and who use base16-shell. DO NOT use this theme simply
9+ because your terminal supports 256 colors.
10+
11+ base16: https://github.com/chriskempson/base16
12+ base16-shell: https://github.com/chriskempson/base16-shell
13+
14+ The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
15+ palette number from 00 to ff (the 256 terminal colors), and AA is the
16+ special value 00 to indicate this encoding is being used.
17+ -->
18+ <key>author</key>
19+ <string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
20+ <key>name</key>
21+ <string>Base16 256</string>
22+ <key>colorSpaceName</key>
23+ <string>sRGB</string>
24+ <key>settings</key>
25+ <array>
26+ <dict>
27+ <key>settings</key>
28+ <dict>
29+ <key>background</key>
30+ <string>#00000000</string>
31+ <key>caret</key>
32+ <string>#07000000</string>
33+ <key>foreground</key>
34+ <string>#07000000</string>
35+ <key>invisibles</key>
36+ <string>#08000000</string>
37+ <key>lineHighlight</key>
38+ <string>#08000000</string>
39+ <key>selection</key>
40+ <string>#13000000</string>
41+ <key>gutter</key>
42+ <string>#12000000</string>
43+ <key>gutterForeground</key>
44+ <string>#08000000</string>
45+ </dict>
46+ </dict>
47+ <dict>
48+ <key>name</key>
49+ <string>Text</string>
50+ <key>scope</key>
51+ <string>variable.parameter.function</string>
52+ <key>settings</key>
53+ <dict>
54+ <key>foreground</key>
55+ <string>#07000000</string>
56+ </dict>
57+ </dict>
58+ <dict>
59+ <key>name</key>
60+ <string>Comments</string>
61+ <key>scope</key>
62+ <string>comment, punctuation.definition.comment</string>
63+ <key>settings</key>
64+ <dict>
65+ <key>foreground</key>
66+ <string>#08000000</string>
67+ </dict>
68+ </dict>
69+ <dict>
70+ <key>name</key>
71+ <string>Punctuation</string>
72+ <key>scope</key>
73+ <string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
74+ <key>settings</key>
75+ <dict>
76+ <key>foreground</key>
77+ <string>#07000000</string>
78+ </dict>
79+ </dict>
80+ <dict>
81+ <key>name</key>
82+ <string>Delimiters</string>
83+ <key>scope</key>
84+ <string>none</string>
85+ <key>settings</key>
86+ <dict>
87+ <key>foreground</key>
88+ <string>#07000000</string>
89+ </dict>
90+ </dict>
91+ <dict>
92+ <key>name</key>
93+ <string>Operators</string>
94+ <key>scope</key>
95+ <string>keyword.operator</string>
96+ <key>settings</key>
97+ <dict>
98+ <key>foreground</key>
99+ <string>#07000000</string>
100+ </dict>
101+ </dict>
102+ <dict>
103+ <key>name</key>
104+ <string>Keywords</string>
105+ <key>scope</key>
106+ <string>keyword</string>
107+ <key>settings</key>
108+ <dict>
109+ <key>foreground</key>
110+ <string>#05000000</string>
111+ </dict>
112+ </dict>
113+ <dict>
114+ <key>name</key>
115+ <string>Variables</string>
116+ <key>scope</key>
117+ <string>variable</string>
118+ <key>settings</key>
119+ <dict>
120+ <key>foreground</key>
121+ <string>#07000000</string>
122+ </dict>
123+ </dict>
124+ <dict>
125+ <key>name</key>
126+ <string>Functions</string>
127+ <key>scope</key>
128+ <string>entity.name.function, meta.require, support.function.any-method</string>
129+ <key>settings</key>
130+ <dict>
131+ <key>foreground</key>
132+ <string>#04000000</string>
133+ </dict>
134+ </dict>
135+ <dict>
136+ <key>name</key>
137+ <string>Labels</string>
138+ <key>scope</key>
139+ <string>entity.name.label</string>
140+ <key>settings</key>
141+ <dict>
142+ <key>foreground</key>
143+ <string>#11000000</string>
144+ </dict>
145+ </dict>
146+ <dict>
147+ <key>name</key>
148+ <string>Classes</string>
149+ <key>scope</key>
150+ <string>support.class, entity.name.class, entity.name.type.class</string>
151+ <key>settings</key>
152+ <dict>
153+ <key>foreground</key>
154+ <string>#03000000</string>
155+ </dict>
156+ </dict>
157+ <dict>
158+ <key>name</key>
159+ <string>Classes</string>
160+ <key>scope</key>
161+ <string>meta.class</string>
162+ <key>settings</key>
163+ <dict>
164+ <key>foreground</key>
165+ <string>#0f000000</string>
166+ </dict>
167+ </dict>
168+ <dict>
169+ <key>name</key>
170+ <string>Methods</string>
171+ <key>scope</key>
172+ <string>keyword.other.special-method</string>
173+ <key>settings</key>
174+ <dict>
175+ <key>foreground</key>
176+ <string>#04000000</string>
177+ </dict>
178+ </dict>
179+ <dict>
180+ <key>name</key>
181+ <string>Storage</string>
182+ <key>scope</key>
183+ <string>storage</string>
184+ <key>settings</key>
185+ <dict>
186+ <key>foreground</key>
187+ <string>#05000000</string>
188+ </dict>
189+ </dict>
190+ <dict>
191+ <key>name</key>
192+ <string>Support</string>
193+ <key>scope</key>
194+ <string>support.function</string>
195+ <key>settings</key>
196+ <dict>
197+ <key>foreground</key>
198+ <string>#06000000</string>
199+ </dict>
200+ </dict>
201+ <dict>
202+ <key>name</key>
203+ <string>Strings, Inherited Class</string>
204+ <key>scope</key>
205+ <string>string, constant.other.symbol, entity.other.inherited-class</string>
206+ <key>settings</key>
207+ <dict>
208+ <key>foreground</key>
209+ <string>#02000000</string>
210+ </dict>
211+ </dict>
212+ <dict>
213+ <key>name</key>
214+ <string>Integers</string>
215+ <key>scope</key>
216+ <string>constant.numeric</string>
217+ <key>settings</key>
218+ <dict>
219+ <key>foreground</key>
220+ <string>#10000000</string>
221+ </dict>
222+ </dict>
223+ <dict>
224+ <key>name</key>
225+ <string>Floats</string>
226+ <key>scope</key>
227+ <string>none</string>
228+ <key>settings</key>
229+ <dict>
230+ <key>foreground</key>
231+ <string>#10000000</string>
232+ </dict>
233+ </dict>
234+ <dict>
235+ <key>name</key>
236+ <string>Boolean</string>
237+ <key>scope</key>
238+ <string>none</string>
239+ <key>settings</key>
240+ <dict>
241+ <key>foreground</key>
242+ <string>#10000000</string>
243+ </dict>
244+ </dict>
245+ <dict>
246+ <key>name</key>
247+ <string>Constants</string>
248+ <key>scope</key>
249+ <string>constant</string>
250+ <key>settings</key>
251+ <dict>
252+ <key>foreground</key>
253+ <string>#10000000</string>
254+ </dict>
255+ </dict>
256+ <dict>
257+ <key>name</key>
258+ <string>Tags</string>
259+ <key>scope</key>
260+ <string>entity.name.tag</string>
261+ <key>settings</key>
262+ <dict>
263+ <key>foreground</key>
264+ <string>#01000000</string>
265+ </dict>
266+ </dict>
267+ <dict>
268+ <key>name</key>
269+ <string>Attributes</string>
270+ <key>scope</key>
271+ <string>entity.other.attribute-name</string>
272+ <key>settings</key>
273+ <dict>
274+ <key>foreground</key>
275+ <string>#10000000</string>
276+ </dict>
277+ </dict>
278+ <dict>
279+ <key>name</key>
280+ <string>Attribute IDs</string>
281+ <key>scope</key>
282+ <string>entity.other.attribute-name.id, punctuation.definition.entity</string>
283+ <key>settings</key>
284+ <dict>
285+ <key>foreground</key>
286+ <string>#04000000</string>
287+ </dict>
288+ </dict>
289+ <dict>
290+ <key>name</key>
291+ <string>Selector</string>
292+ <key>scope</key>
293+ <string>meta.selector</string>
294+ <key>settings</key>
295+ <dict>
296+ <key>foreground</key>
297+ <string>#05000000</string>
298+ </dict>
299+ </dict>
300+ <dict>
301+ <key>name</key>
302+ <string>Values</string>
303+ <key>scope</key>
304+ <string>none</string>
305+ <key>settings</key>
306+ <dict>
307+ <key>foreground</key>
308+ <string>#10000000</string>
309+ </dict>
310+ </dict>
311+ <dict>
312+ <key>name</key>
313+ <string>Headings</string>
314+ <key>scope</key>
315+ <string>markup.heading punctuation.definition.heading, entity.name.section</string>
316+ <key>settings</key>
317+ <dict>
318+ <key>fontStyle</key>
319+ <string></string>
320+ <key>foreground</key>
321+ <string>#04000000</string>
322+ </dict>
323+ </dict>
324+ <dict>
325+ <key>name</key>
326+ <string>Units</string>
327+ <key>scope</key>
328+ <string>keyword.other.unit</string>
329+ <key>settings</key>
330+ <dict>
331+ <key>foreground</key>
332+ <string>#10000000</string>
333+ </dict>
334+ </dict>
335+ <dict>
336+ <key>name</key>
337+ <string>Bold</string>
338+ <key>scope</key>
339+ <string>markup.bold, punctuation.definition.bold</string>
340+ <key>settings</key>
341+ <dict>
342+ <key>fontStyle</key>
343+ <string>bold</string>
344+ <key>foreground</key>
345+ <string>#03000000</string>
346+ </dict>
347+ </dict>
348+ <dict>
349+ <key>name</key>
350+ <string>Italic</string>
351+ <key>scope</key>
352+ <string>markup.italic, punctuation.definition.italic</string>
353+ <key>settings</key>
354+ <dict>
355+ <key>fontStyle</key>
356+ <string>italic</string>
357+ <key>foreground</key>
358+ <string>#05000000</string>
359+ </dict>
360+ </dict>
361+ <dict>
362+ <key>name</key>
363+ <string>Code</string>
364+ <key>scope</key>
365+ <string>markup.raw.inline</string>
366+ <key>settings</key>
367+ <dict>
368+ <key>foreground</key>
369+ <string>#02000000</string>
370+ </dict>
371+ </dict>
372+ <dict>
373+ <key>name</key>
374+ <string>Link Text</string>
375+ <key>scope</key>
376+ <string>string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown</string>
377+ <key>settings</key>
378+ <dict>
379+ <key>foreground</key>
380+ <string>#01000000</string>
381+ </dict>
382+ </dict>
383+ <dict>
384+ <key>name</key>
385+ <string>Link Url</string>
386+ <key>scope</key>
387+ <string>meta.link</string>
388+ <key>settings</key>
389+ <dict>
390+ <key>foreground</key>
391+ <string>#10000000</string>
392+ </dict>
393+ </dict>
394+ <dict>
395+ <key>name</key>
396+ <string>Quotes</string>
397+ <key>scope</key>
398+ <string>markup.quote</string>
399+ <key>settings</key>
400+ <dict>
401+ <key>foreground</key>
402+ <string>#10000000</string>
403+ </dict>
404+ </dict>
405+ <dict>
406+ <key>name</key>
407+ <string>Separator</string>
408+ <key>scope</key>
409+ <string>meta.separator</string>
410+ <key>settings</key>
411+ <dict>
412+ <key>background</key>
413+ <string>#13000000</string>
414+ <key>foreground</key>
415+ <string>#07000000</string>
416+ </dict>
417+ </dict>
418+ <dict>
419+ <key>name</key>
420+ <string>Inserted</string>
421+ <key>scope</key>
422+ <string>markup.inserted</string>
423+ <key>settings</key>
424+ <dict>
425+ <key>foreground</key>
426+ <string>#02000000</string>
427+ </dict>
428+ </dict>
429+ <dict>
430+ <key>name</key>
431+ <string>Deleted</string>
432+ <key>scope</key>
433+ <string>markup.deleted</string>
434+ <key>settings</key>
435+ <dict>
436+ <key>foreground</key>
437+ <string>#01000000</string>
438+ </dict>
439+ </dict>
440+ <dict>
441+ <key>name</key>
442+ <string>Changed</string>
443+ <key>scope</key>
444+ <string>markup.changed</string>
445+ <key>settings</key>
446+ <dict>
447+ <key>foreground</key>
448+ <string>#05000000</string>
449+ </dict>
450+ </dict>
451+ <dict>
452+ <key>name</key>
453+ <string>Colors</string>
454+ <key>scope</key>
455+ <string>constant.other.color</string>
456+ <key>settings</key>
457+ <dict>
458+ <key>foreground</key>
459+ <string>#06000000</string>
460+ </dict>
461+ </dict>
462+ <dict>
463+ <key>name</key>
464+ <string>Regular Expressions</string>
465+ <key>scope</key>
466+ <string>string.regexp</string>
467+ <key>settings</key>
468+ <dict>
469+ <key>foreground</key>
470+ <string>#06000000</string>
471+ </dict>
472+ </dict>
473+ <dict>
474+ <key>name</key>
475+ <string>Escape Characters</string>
476+ <key>scope</key>
477+ <string>constant.character.escape</string>
478+ <key>settings</key>
479+ <dict>
480+ <key>foreground</key>
481+ <string>#06000000</string>
482+ </dict>
483+ </dict>
484+ <dict>
485+ <key>name</key>
486+ <string>Embedded</string>
487+ <key>scope</key>
488+ <string>punctuation.section.embedded, variable.interpolation</string>
489+ <key>settings</key>
490+ <dict>
491+ <key>foreground</key>
492+ <string>#05000000</string>
493+ </dict>
494+ </dict>
495+ <dict>
496+ <key>name</key>
497+ <string>Illegal</string>
498+ <key>scope</key>
499+ <string>invalid.illegal</string>
500+ <key>settings</key>
501+ <dict>
502+ <key>background</key>
503+ <string>#01000000</string>
504+ <key>foreground</key>
505+ <string>#0f000000</string>
506+ </dict>
507+ </dict>
508+ <dict>
509+ <key>name</key>
510+ <string>Broken</string>
511+ <key>scope</key>
512+ <string>invalid.broken</string>
513+ <key>settings</key>
514+ <dict>
515+ <key>background</key>
516+ <string>#10000000</string>
517+ <key>foreground</key>
518+ <string>#00000000</string>
519+ </dict>
520+ </dict>
521+ <dict>
522+ <key>name</key>
523+ <string>Deprecated</string>
524+ <key>scope</key>
525+ <string>invalid.deprecated</string>
526+ <key>settings</key>
527+ <dict>
528+ <key>background</key>
529+ <string>#11000000</string>
530+ <key>foreground</key>
531+ <string>#0f000000</string>
532+ </dict>
533+ </dict>
534+ <dict>
535+ <key>name</key>
536+ <string>Unimplemented</string>
537+ <key>scope</key>
538+ <string>invalid.unimplemented</string>
539+ <key>settings</key>
540+ <dict>
541+ <key>background</key>
542+ <string>#08000000</string>
543+ <key>foreground</key>
544+ <string>#0f000000</string>
545+ </dict>
546+ </dict>
547+ </array>
548+ <key>uuid</key>
549+ <string>uuid</string>
550+ </dict>
551+</plist>
assets/themes/base16.tmTheme+9−2
@@ -3,9 +3,16 @@
33<plist version="1.0">
44 <dict>
55 <!--
6+ This theme is meant for users who configure their terminal with a base16
7+ color theme. If you use a 256-color variant along with base16-shell, use
8+ the bat theme base16-256 instead.
9+
10+ base16: https://github.com/chriskempson/base16
11+ base16-shell: https://github.com/chriskempson/base16-shell
12+
613 The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
7− palette number from 00 to 0f, and AA is the special value 00 to indicate
8− that this encoding is being used.
14+ palette number from 00 to 0f (the 8 colors and their bright versions),
15+ and AA is the special value 00 to indicate this encoding is being used.
916 -->
1017 <key>author</key>
1118 <string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
src/terminal.rs+1−1
@@ -8,7 +8,7 @@ pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term:
88 // Themes can specify one of the user-configurable terminal colors by
99 // encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set
1010 // to the 8-bit color palette number. The built-in themes ansi-light,
11− // ansi-dark, and base16 use this.
11+ // ansi-dark, base16, and base16-256 use this.
1212 match color.r {
1313 // For the first 8 colors, use the Color enum to produce ANSI escape
1414 // sequences using codes 30-37 (foreground) and 40-47 (background).