on master help sign in
Add customization chapter
commit64ef61b40927d0ac9881cace2b6e37dfc9706f90 authorsharkdp <davidpeter@web.de> dateMon 30 Apr 2018, 16:03 (9 years ago) parent95a2079
4 files changed+39−3
Cargo.lock+1−1 Cargo.toml+1−1 README.md+35 src/main.rs+2−1
Cargo.lock+1−1
@@ -61,7 +61,7 @@ dependencies = [
6161
6262[[package]]
6363name = "bat"
64−version = "0.1.0"
64+version = "0.2.0"
6565dependencies = [
6666 "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
6767 "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
Cargo.toml+1−1
@@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
77name = "bat"
88readme = "README.md"
99repository = "https://github.com/sharkdp/bat"
10−version = "0.1.0"
10+version = "0.2.0"
1111
1212[dependencies]
1313atty = "0.2.2"
README.md+35
@@ -32,3 +32,38 @@ Make sure that you have the devel-version of libopenssl installed (see instructi
3232``` bash
3333cargo install bat
3434```
35+
36+## Customization
37+
38+`bat` uses the excellent [`syntect`](https://github.com/trishume/syntect/) library for syntax highlighting. `syntect` can read any Sublime Text language definitions and highlighting theme.
39+
40+To build your own syntax-set and theme, follow these steps:
41+
42+Create a folder with syntax highlighting theme:
43+``` bash
44+mkdir -p ~/.config/bat/themes
45+cd ~/.config/bat/themes
46+
47+# Download a theme, for example:
48+git clone https://github.com/jonschlinkert/sublime-monokai-extended
49+
50+# Create a 'Default.tmTheme' link
51+ln -s "sublime-monokai-extended/Monokai Extended.tmTheme" Default.tmTheme
52+```
53+
54+Create a folder with language definition files:
55+``` bash
56+mkdir -p ~/.config/bat/syntax
57+cd ~/.config/bat/syntax
58+
59+# Download some language definition files, for example:
60+git clone https://github.com/sublimehq/Packages/
61+rm -rf Packages/Markdown
62+git clone https://github.com/jonschlinkert/sublime-markdown-extended
63+```
64+
65+Finally, use the following command to parse all these files into a binary
66+cache:
67+``` bash
68+bat init-cache
69+```
src/main.rs+2−1
@@ -368,7 +368,8 @@ fn run() -> Result<()> {
368368 true_color: is_truecolor_terminal(),
369369 };
370370
371− let assets = HighlightingAssets::from_binary();
371+ let assets =
372+ HighlightingAssets::from_cache().unwrap_or(HighlightingAssets::from_binary());
372373
373374 let theme = assets.theme_set.themes.get("Default").ok_or_else(|| {
374375 io::Error::new(