mirror of
https://github.com/sharkdp/bat.git
synced 2025-04-26 20:48:38 +02:00
Add customization chapter
This commit is contained in:
parent
95a2079bcd
commit
64ef61b409
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -61,7 +61,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bat"
|
name = "bat"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
|
|||||||
name = "bat"
|
name = "bat"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/sharkdp/bat"
|
repository = "https://github.com/sharkdp/bat"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
atty = "0.2.2"
|
atty = "0.2.2"
|
||||||
|
35
README.md
35
README.md
@ -32,3 +32,38 @@ Make sure that you have the devel-version of libopenssl installed (see instructi
|
|||||||
``` bash
|
``` bash
|
||||||
cargo install bat
|
cargo install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
`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.
|
||||||
|
|
||||||
|
To build your own syntax-set and theme, follow these steps:
|
||||||
|
|
||||||
|
Create a folder with syntax highlighting theme:
|
||||||
|
``` bash
|
||||||
|
mkdir -p ~/.config/bat/themes
|
||||||
|
cd ~/.config/bat/themes
|
||||||
|
|
||||||
|
# Download a theme, for example:
|
||||||
|
git clone https://github.com/jonschlinkert/sublime-monokai-extended
|
||||||
|
|
||||||
|
# Create a 'Default.tmTheme' link
|
||||||
|
ln -s "sublime-monokai-extended/Monokai Extended.tmTheme" Default.tmTheme
|
||||||
|
```
|
||||||
|
|
||||||
|
Create a folder with language definition files:
|
||||||
|
``` bash
|
||||||
|
mkdir -p ~/.config/bat/syntax
|
||||||
|
cd ~/.config/bat/syntax
|
||||||
|
|
||||||
|
# Download some language definition files, for example:
|
||||||
|
git clone https://github.com/sublimehq/Packages/
|
||||||
|
rm -rf Packages/Markdown
|
||||||
|
git clone https://github.com/jonschlinkert/sublime-markdown-extended
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, use the following command to parse all these files into a binary
|
||||||
|
cache:
|
||||||
|
``` bash
|
||||||
|
bat init-cache
|
||||||
|
```
|
||||||
|
@ -368,7 +368,8 @@ fn run() -> Result<()> {
|
|||||||
true_color: is_truecolor_terminal(),
|
true_color: is_truecolor_terminal(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let assets = HighlightingAssets::from_binary();
|
let assets =
|
||||||
|
HighlightingAssets::from_cache().unwrap_or(HighlightingAssets::from_binary());
|
||||||
|
|
||||||
let theme = assets.theme_set.themes.get("Default").ok_or_else(|| {
|
let theme = assets.theme_set.themes.get("Default").ok_or_else(|| {
|
||||||
io::Error::new(
|
io::Error::new(
|
||||||
|
Loading…
Reference in New Issue
Block a user