1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-04 19:01:44 +00:00

Compare commits

...

61 Commits

Author SHA1 Message Date
sharkdp 79f016e15c Update syntaxes 2019-08-31 20:58:16 +02:00
sharkdp 26f9125ebb Re-formulate help text 2019-08-31 20:56:53 +02:00
sharkdp 9814eab13f Suppress warning in -A mode 2019-08-31 20:56:53 +02:00
sharkdp 82ca8804a2 Handle non-unicode characters in the preprocessor 2019-08-31 20:56:53 +02:00
pjsier b48b9fcf3b Display binary file content for bat -A 2019-08-31 20:56:53 +02:00
sharkdp c64ab29739 Update min. required rust version 2019-08-31 14:48:42 +02:00
sharkdp 83dd3fb551 Update man page 2019-08-31 14:47:04 +02:00
sharkdp ed345f2889 Fix headline 2019-08-31 14:44:11 +02:00
sharkdp d2492980c0 Update syntaxes and themes 2019-08-31 14:43:20 +02:00
sharkdp 47d5130764 Bump version 2019-08-31 14:43:04 +02:00
sharkdp 4ba45e2ba2 Add first version of 'man page' syntax, closes #523 2019-08-31 14:32:37 +02:00
sharkdp 7076ae5cd9 Update dependencies 2019-08-31 14:14:08 +02:00
sharkdp 2e71146801 Fix another instance of the 'bat cache' bug, closes #584 2019-08-31 14:13:36 +02:00
sharkdp f3824bad17 Add explicit terminal width for test 2019-08-31 13:46:48 +02:00
sharkdp ec908d5937 Run 'cargo fmt' 2019-08-31 13:46:48 +02:00
sharkdp 3a75d85b80 Add test for 'snip' feature 2019-08-31 13:46:48 +02:00
sharkdp 63d652dab5 Add 'dyn' keyword for trait references 2019-08-31 13:46:48 +02:00
Ethan P 7f2e61d579 Add new style component to separate multiple '--line-range's 2019-08-31 13:46:48 +02:00
sharkdp e289a2c698 Add short '-L' option as an alias for --list-languages 2019-08-31 13:22:16 +02:00
sharkdp 83a213bae7 Add 'strace' syntax, closes #599 2019-08-31 13:13:42 +02:00
sharkdp 3967e28ded Add SCSS and Sass syntax, closes #637 2019-08-31 13:09:38 +02:00
sharkdp 2dc2a3712a Add Verilog syntax, closes #616 2019-08-31 12:59:02 +02:00
sharkdp 10e0f9efb0 Install fish completions in DEB package, closes #554 2019-08-28 21:06:52 +02:00
dependabot-preview[bot] f8ea075e78 Bump console from 0.7.7 to 0.8.0
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.7 to 0.8.0.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.7.7...0.8.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-26 21:44:57 +02:00
dependabot-preview[bot] c187dce2c2 Bump lazy_static from 1.3.0 to 1.4.0
Bumps [lazy_static](https://github.com/rust-lang-nursery/lazy-static.rs) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/rust-lang-nursery/lazy-static.rs/releases)
- [Commits](https://github.com/rust-lang-nursery/lazy-static.rs/compare/1.3.0...1.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-26 07:13:01 +02:00
dependabot-preview[bot] 108c907d69 Bump git2 from 0.9.2 to 0.10.0
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.9.2 to 0.10.0.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-curl-0.9.2...git2-curl-0.10.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-24 08:47:50 +02:00
sharkdp 187a3b9341 Use consistent syntax for command-line options
closes #574
2019-08-15 21:57:32 +02:00
David Peter 9c2d4f6a51 Add libc6-dev dependency for aarch64 2019-08-10 15:58:13 +02:00
sharkdp c1126157d4 Re-enable aarch64 builds 2019-08-10 15:58:13 +02:00
dependabot-preview[bot] dcfa810112 Bump syntect from 3.2.0 to 3.2.1
Bumps [syntect](https://github.com/trishume/syntect) from 3.2.0 to 3.2.1.
- [Release notes](https://github.com/trishume/syntect/releases)
- [Changelog](https://github.com/trishume/syntect/blob/master/CHANGELOG.md)
- [Commits](https://github.com/trishume/syntect/compare/v3.2.0...v3.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-10 14:06:13 +02:00
Dan Davison f963104006 Add GraphQL sublime syntax submodule 2019-08-10 13:17:02 +02:00
sharkdp 45e1c0ea6f Temporarily disable aarch64 2019-08-02 21:14:44 +02:00
sharkdp 590a1e9a4b Bump minimum supported version to 1.33 2019-08-02 21:00:33 +02:00
sharkdp 8e2c6abb13 Update dependencies 2019-08-02 20:57:16 +02:00
Wild Kat 28266ee441 use explicit dyn with Write to appease compiler 2019-08-02 18:50:55 +02:00
Ethan P 21821f1d4c Updated snapshot tests 2019-07-26 06:51:33 +02:00
Ethan P 772ce2e4fe Print a horizontal header line when 'grid' style without 'header' style 2019-07-26 06:51:33 +02:00
dependabot-preview[bot] 35ca1c5191 Bump atty from 0.2.12 to 0.2.13
Bumps [atty](https://github.com/softprops/atty) from 0.2.12 to 0.2.13.
- [Release notes](https://github.com/softprops/atty/releases)
- [Changelog](https://github.com/softprops/atty/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/atty/compare/0.2.12...0.2.13)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-25 21:34:19 +02:00
dependabot-preview[bot] 0cc60a1519 Bump wild from 2.0.1 to 2.0.2
Bumps [wild](https://gitlab.com/kornelski/wild) from 2.0.1 to 2.0.2.
- [Release notes](https://gitlab.com/kornelski/wild/tags)
- [Commits](https://gitlab.com/kornelski/wild/commits/master)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-24 21:50:05 +02:00
dependabot-preview[bot] ee6659dacf Bump ansi_term from 0.11.0 to 0.12.0
Bumps [ansi_term](https://github.com/ogham/rust-ansi-term) from 0.11.0 to 0.12.0.
- [Release notes](https://github.com/ogham/rust-ansi-term/releases)
- [Commits](https://github.com/ogham/rust-ansi-term/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-24 21:45:44 +02:00
sharkdp 76c615a304 Allow leading minus in '--terminal-width <value>'
closes #611
2019-07-24 21:44:25 +02:00
Igor Gnatenko e8c04672f0 Small improvements for Fedora instructions
Anything older than F29 is EOL now, so no need to mention it. Also in F29+ you can use standard `dnf install`.
2019-07-24 21:38:11 +02:00
dependabot-preview[bot] 7f5a5612e4 Bump atty from 0.2.11 to 0.2.12
Bumps [atty](https://github.com/softprops/atty) from 0.2.11 to 0.2.12.
- [Release notes](https://github.com/softprops/atty/releases)
- [Changelog](https://github.com/softprops/atty/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/atty/compare/0.2.11...0.2.12)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-12 07:15:42 +02:00
dependabot-preview[bot] eee5d424bb [Security] Bump smallvec from 0.6.9 to 0.6.10
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 0.6.9 to 0.6.10. **This update includes security fixes.**
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-07 15:34:01 +02:00
dependabot-preview[bot] e5311e4b30 Bump console from 0.7.6 to 0.7.7
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.6 to 0.7.7.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.7.6...0.7.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-05 14:34:15 +02:00
dependabot-preview[bot] a1b9334a44 Bump console from 0.7.5 to 0.7.6
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.5 to 0.7.6.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.7.5...0.7.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-06-20 10:04:08 +02:00
Chloe Kudryavtsev d86b7cf7e0 Add Alpine Linux installation instructions
Resolves #586
2019-06-11 07:40:23 +02:00
dependabot-preview[bot] 67834da681 Bump git2 from 0.9.0 to 0.9.1
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.9.0 to 0.9.1.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.9.0...0.9.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-06-10 11:15:51 +02:00
toku-sa-n dcdf8dfaa7 Add install instructions(ja) for Gentoo Users. 2019-06-09 17:50:18 +02:00
toku-sa-n 9a44fa11c0 Add install instructions for Gentoo Users. 2019-06-09 17:50:18 +02:00
sharkdp 4ee0b2e16d Merge branch 'issmirnov-ssh-config' 2019-06-07 08:17:17 +02:00
sharkdp 518997135e Merge branch 'ssh-config' of https://github.com/issmirnov/bat into issmirnov-ssh-config 2019-06-07 08:17:04 +02:00
Ivan Smirnov 69fc1caead Add support for "etc/hosts" files.
- Syntax author: https://github.com/brandonwamboldt/sublime-hosts

Since the upstream version only has a tmLanguage, added a sublime-syntax
file manually.
2019-06-07 08:02:38 +02:00
Ivan Smirnov 175dd4c290 Add SSH config syntax
Tested:
```
bash assets/create.sh
cargo build
target/debug/bat --language ssh_config ~/.ssh/config
```
2019-06-06 20:01:23 -07:00
dependabot-preview[bot] e9210c0f6c Bump git2 from 0.8.0 to 0.9.0
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.8.0 to 0.9.0.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-curl-0.8.0...0.9.0)
2019-06-05 07:17:09 +02:00
sharkdp 3795acbd17 Add '.env' (DotENV) syntax 2019-05-31 21:05:34 +02:00
sharkdp c7d08cfcfd Add 'requirements.txt' syntax 2019-05-31 20:58:08 +02:00
dependabot-preview[bot] 8ec96da9f0 Bump dirs from 2.0.0 to 2.0.1
Bumps [dirs](https://github.com/soc/dirs-rs) from 2.0.0 to 2.0.1.
- [Release notes](https://github.com/soc/dirs-rs/releases)
- [Commits](https://github.com/soc/dirs-rs/commits)
2019-05-31 08:57:04 +02:00
Fernando Mendes c9d7e3652b Enforce the creation of the full cache dir path
Fixes #576
2019-05-30 22:28:52 +02:00
Brice Waegeneire dfa024f9e6 Add Org mode syntax, closes sharkdp#36 2019-05-29 19:52:06 +02:00
dependabot-preview[bot] b2757cb461 Bump dirs from 1.0.5 to 2.0.0
Bumps [dirs](https://github.com/soc/dirs-rs) from 1.0.5 to 2.0.0.
- [Release notes](https://github.com/soc/dirs-rs/releases)
- [Commits](https://github.com/soc/dirs-rs/commits)
2019-05-28 21:32:57 +02:00
40 changed files with 1387 additions and 577 deletions
+27
View File
@@ -126,3 +126,30 @@
[submodule "assets/syntaxes/sublime-fish"] [submodule "assets/syntaxes/sublime-fish"]
path = assets/syntaxes/sublime-fish path = assets/syntaxes/sublime-fish
url = https://github.com/Phidica/sublime-fish.git url = https://github.com/Phidica/sublime-fish.git
[submodule "assets/syntaxes/Org mode"]
path = assets/syntaxes/Org mode
url = https://github.com/jezcope/Org.tmbundle.git
[submodule "assets/syntaxes/requirementstxt"]
path = assets/syntaxes/requirementstxt
url = https://github.com/wuub/requirementstxt
[submodule "assets/syntaxes/DotENV"]
path = assets/syntaxes/DotENV
url = https://github.com/zaynali53/DotENV
[submodule "assets/syntaxes/hosts"]
path = assets/syntaxes/hosts
url = https://github.com/brandonwamboldt/sublime-hosts
[submodule "assets/syntaxes/ssh-config"]
path = assets/syntaxes/ssh-config
url = https://github.com/robballou/sublimetext-sshconfig.git
[submodule "assets/syntaxes/GraphQL"]
path = assets/syntaxes/GraphQL
url = https://github.com/dncrews/GraphQL-SublimeText3.git
[submodule "assets/syntaxes/Verilog"]
path = assets/syntaxes/Verilog
url = https://github.com/pro711/sublime-verilog
[submodule "assets/syntaxes/SCSS_Sass"]
path = assets/syntaxes/SCSS_Sass
url = https://github.com/braver/SublimeSass
[submodule "assets/syntaxes/Strace"]
path = assets/syntaxes/Strace
url = https://github.com/djuretic/SublimeStrace
+3 -3
View File
@@ -32,15 +32,15 @@ matrix:
# Minimum Rust supported channel. # Minimum Rust supported channel.
- os: linux - os: linux
rust: 1.31.0 rust: 1.35.0
env: TARGET=x86_64-unknown-linux-gnu env: TARGET=x86_64-unknown-linux-gnu
- os: linux - os: linux
rust: 1.31.0 rust: 1.35.0
env: env:
- TARGET=x86_64-unknown-linux-musl - TARGET=x86_64-unknown-linux-musl
- CC_x86_64_unknown_linux_musl=/usr/bin/musl-gcc - CC_x86_64_unknown_linux_musl=/usr/bin/musl-gcc
- os: osx - os: osx
rust: 1.31.0 rust: 1.35.0
env: TARGET=x86_64-apple-darwin env: TARGET=x86_64-apple-darwin
# Code formatting check # Code formatting check
Generated
+427 -450
View File
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -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.11.0" version = "0.12.0"
exclude = [ exclude = [
"assets/syntaxes/*", "assets/syntaxes/*",
"assets/themes/*", "assets/themes/*",
@@ -16,24 +16,24 @@ build = "build.rs"
edition = '2018' edition = '2018'
[dependencies] [dependencies]
atty = "0.2.2" atty = "0.2.13"
ansi_term = "0.11" ansi_term = "0.12"
ansi_colours = "^1.0" ansi_colours = "^1.0"
console = "0.7" console = "0.8"
dirs = "1.0" dirs = "2.0"
lazy_static = "1.3" lazy_static = "1.4"
wild = "2.0" wild = "2.0"
content_inspector = "0.2.4" content_inspector = "0.2.4"
encoding = "0.2" encoding = "0.2"
shell-words = "0.1.0" shell-words = "0.1.0"
[dependencies.git2] [dependencies.git2]
version = "0.8" version = "0.10"
default-features = false default-features = false
features = [] features = []
[dependencies.syntect] [dependencies.syntect]
version = "3.2.0" version = "3.2.1"
default-features = false default-features = false
features = ["parsing", "yaml-load", "dump-load", "dump-create"] features = ["parsing", "yaml-load", "dump-load", "dump-create"]
+34 -5
View File
@@ -114,7 +114,7 @@ tail -f /var/log/pacman.log | bat --paging=never -l log
Note that we have to switch off paging in order for this to work. We have also specified the syntax Note that we have to switch off paging in order for this to work. We have also specified the syntax
explicitly (`-l log`), as it can not be auto-detected in this case. explicitly (`-l log`), as it can not be auto-detected in this case.
### `git show` #### `git show`
You can combine `bat` with `git show` to view an older version of a given file with proper syntax You can combine `bat` with `git show` to view an older version of a given file with proper syntax
highlighting: highlighting:
@@ -132,6 +132,17 @@ bat main.cpp | xclip
``` ```
`bat` will detect that the output is being redirected and print the plain file contents. `bat` will detect that the output is being redirected and print the plain file contents.
#### `man`
`bat` can be used as a pager for `man`. It can be used like this:
```
export MANPAGER="sh -c 'col -b | bat -l man -p'"
man 2 select
```
The [Manpage syntax](assets/syntaxes/Manpage.sublime-syntax) is developed in this repository and still needs some work.
## Installation ## Installation
### On Ubuntu ### On Ubuntu
@@ -140,7 +151,16 @@ bat main.cpp | xclip
Download the latest `.deb` package from the [release page](https://github.com/sharkdp/bat/releases) Download the latest `.deb` package from the [release page](https://github.com/sharkdp/bat/releases)
and install it via: and install it via:
``` bash ``` bash
sudo dpkg -i bat_0.11.0_amd64.deb # adapt version number and architecture sudo dpkg -i bat_0.12.0_amd64.deb # adapt version number and architecture
```
### On Alpine Linux
You can install [the `bat` package](https://pkgs.alpinelinux.org/packages?name=bat)
from the official sources, provided you have the appropriate repository enabled:
```bash
apk add bat
``` ```
### On Arch Linux ### On Arch Linux
@@ -154,10 +174,19 @@ pacman -S bat
### On Fedora ### On Fedora
You can install `bat` from the [Fedora Modular](https://docs.fedoraproject.org/en-US/modularity/using-modules/) repository. On Fedora 29 and higher, it is enabled by default. Otherwise, run `dnf install fedora-repos-modular` to set up, and make sure that the `fedora-modular` and `fedora-updates-modular` repos are enabled in `/etc/yum.repos.d`. You can install [the `bat` package](https://koji.fedoraproject.org/koji/packageinfo?packageID=27506) from the official [Fedora Modular](https://docs.fedoraproject.org/en-US/modularity/using-modules/) repository.
```bash ```bash
dnf module install bat dnf install bat
```
### On Gentoo Linux
You can install [the `bat` package](https://packages.gentoo.org/packages/sys-apps/bat)
from the official sources:
```bash
emerge sys-apps/bat
``` ```
### On Void Linux ### On Void Linux
@@ -265,7 +294,7 @@ binaries are also available: look for archives with `musl` in the file name.
### From source ### From source
If you want to build `bat` from source, you need Rust 1.31 or If you want to build `bat` from source, you need Rust 1.35 or
higher. You can then use `cargo` to build everything: higher. You can then use `cargo` to build everything:
```bash ```bash
+1
View File
@@ -33,6 +33,7 @@ The following files have been manually modified after converting from a `.tmLang
* `Dart.sublime-syntax` => removed `#regex.dart` include. * `Dart.sublime-syntax` => removed `#regex.dart` include.
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types. * `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types.
* `Org mode.sublime-syntax` => removed `task` file type.
### Non-submodule additions ### Non-submodule additions
BIN
View File
Binary file not shown.
Vendored Submodule
+1
Submodule assets/syntaxes/DotENV added at f6cad1140c
+88
View File
@@ -0,0 +1,88 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: DotENV
file_extensions:
- .env
- .envrc
- .env.dist
- .env.local
- .env.sample
- .env.example
- .env.test
- .env.test.local
- .env.dev
- .env.development
- .env.development.local
- .env.prod
- .env.production
- .env.production.local
- .env.dusk.local
scope: source.env
contexts:
main:
- match: (#).*$\n?
comment: "Comments - starts with #"
scope: comment.line.number-sign.env
captures:
1: punctuation.definition.comment.env
- match: (\")
comment: Strings (double)
captures:
1: punctuation.definition.string.begin.env
push:
- meta_scope: string.quoted.double.env
- match: (\")
captures:
1: punctuation.definition.string.end
pop: true
- include: interpolation
- include: variable
- include: escape-characters
- match: (\')
comment: Strings (single)
captures:
1: punctuation.definition.string.begin.env
push:
- meta_scope: string.quoted.single.env
- match: (\')
captures:
1: punctuation.definition.string.end
pop: true
- match: '(?<=[\w])\s?='
comment: Assignment Operator
scope: keyword.operator.assignment.env
- match: '([\w]+)(?=\s?\=)'
comment: Variable
scope: variable.other.env
- match: (?i)\s?(export)
comment: Keywords
scope: keyword.other.env
- match: (?i)(?<=\=)\s?(true|false|null)
comment: Constants
scope: constant.language.env
- match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b'
comment: Numeric
scope: constant.numeric.env
escape-characters:
- match: '\\[nrt\\\$\"\'']'
scope: constant.character.escape.env
interpolation:
- match: '(\$\{|\{)'
comment: 'Template Syntax: "foo ${bar} {$baz}"'
captures:
1: string.interpolated.env keyword.other.template.begin.env
push:
- match: '(\})'
captures:
1: string.interpolated.env keyword.other.template.end.env
pop: true
- match: '(?x)(\$+)?([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)'
captures:
1: punctuation.definition.variable.env variable.other.env
2: variable.other.env
variable:
- match: '(?x)(\$+)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)'
captures:
1: punctuation.definition.variable.env variable.other.env
2: variable.other.env
Vendored Submodule
+1
Submodule assets/syntaxes/GraphQL added at 66ce8713d8
+23
View File
@@ -0,0 +1,23 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: hosts
file_extensions:
- hosts
scope: source.hosts
contexts:
main:
- scope: comment.line.number-sign
match: \#.*
comment: comment
- match: ^\s*([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|[0-9a-f:]+)
comment: ipaddress
scope: constant.numeric.ipaddress
- match: \s(localhost|ip6-loopback|ip6-localhost|ip6-localnet|ip6-mcastprefix|ip6-allnodes|ip6-allrouters|ip6-allhosts|broadcasthost)\b
scope: keyword.host.predefined}
comment: prefdfined
+44
View File
@@ -0,0 +1,44 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Manpage
file_extensions:
- man
scope: source.man
variables:
section_heading: '^\S.*$'
contexts:
main:
- match: ^
push: first_line
first_line:
- match: '([A-Z0-9]+)(\()([^)]+)(\))'
captures:
1: meta.preprocessor
2: keyword.operator
3: string.quoted.other
4: keyword.operator
- match: '$'
push: body
body:
- match: '^(SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)'
push: Packages/C/C.sublime-syntax
scope: markup.heading
with_prototype:
- match: '(?={{section_heading}})'
pop: true
- match: '^\S.*$'
scope: markup.heading
- match: '\b([a-z0-9_]+)(\()([^)]*)(\))'
captures:
1: entity.name.function
2: keyword.operator
3: constant.numeric
4: keyword.operator
Vendored Submodule
+1
+219
View File
@@ -0,0 +1,219 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: orgmode
file_extensions:
- org
scope: text.orgmode
contexts:
main:
- match: |-
(?x)
^(\*+) # leading stars
\s*([A-Z_]{2,})? # todo keywords
\s*(\[\#[A-Ca-c]\])? # priority
\s*(?=\s+[A-Za-z0-9]+) # expected heading text
comment: Outline headings
captures:
1: punctuation.definition.heading.orgmode
2: keyword.other.todo.orgmode
3: constant.other.priority.orgmode
push:
- meta_scope: markup.heading.orgmode
- meta_content_scope: entity.name.section.orgmode
- match: (?=\s*$\n?)
pop: true
- include: heading-inline
- match: "^-{5,}$"
scope: meta.separator.orgmode
- match: '^\s*([-+]|\s+\*)\s+(.*?)\s+::'
captures:
1: keyword.operator.list.orgmode
2: markup.bold.definition.orgmode
push:
- meta_scope: meta.list.definition.orgmode
- match: $
pop: true
- include: inline
- match: '^\s*?([-+]|\s+\*|\d+[).])'
captures:
1: keyword.operator.list.orgmode
push:
- meta_scope: meta.list.plain.orgmode
- match: $
pop: true
- include: list-inline
- match: (?i)^#\+(BEGIN_(QUOTE|VERSE|CENTER))$
captures:
1: keyword.control.block.orgmode
push:
- meta_scope: markup.quote.orgmode
- match: (?i)^#\+(END_\2)$
captures:
1: keyword.control.block.orgmode
pop: true
- match: "^#[^+].*$"
scope: comment.line.number-sign.orgmode
- match: ^:(PROPERTIES):$
captures:
1: keyword.control.drawer.orgmode
push:
- meta_scope: meta.drawer.properties.orgmode
- match: ^:(END):$
captures:
1: keyword.control.drawer.orgmode
pop: true
- include: properties
- match: ^:(.+):$
captures:
1: keyword.control.drawer.orgmode
push:
- meta_scope: meta.drawer.other.orgmode
- match: ^:(END):$
captures:
1: keyword.control.drawer.orgmode
pop: true
- match: (?i)#\+(BEGIN_LaTeX)$
captures:
1: keyword.control.block.orgmode
push:
- meta_scope: meta.block.latex.orgmode
- match: (?i)#\+(END_LaTeX)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:text.tex.latex
- match: (?i)#\+(BEGIN_HTML)$
captures:
1: keyword.control.block.orgmode
push:
- meta_scope: meta.block.html.orgmode
- match: (?i)#\+(END_HTML)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:text.html.basic
- match: (?i)#\+(BEGIN_SRC)\s+(python)\s*(.*)$
captures:
1: keyword.control.block.orgmode
2: constant.other.language.orgmode
3: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.python.orgmode
- match: (?i)#\+(END_SRC)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:source.python
- match: (?i)#\+(BEGIN_SRC)\s+(ruby)\s*(.*)$
captures:
1: keyword.control.block.orgmode
2: constant.other.language.orgmode
3: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.ruby.orgmode
- match: (?i)#\+(END_SRC)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:source.ruby
- match: (?i)#\+(BEGIN_SRC)\s+((?:emacs-)?lisp)\s*(.*)$
captures:
1: keyword.control.block.orgmode
2: constant.other.language.orgmode
3: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.lisp.orgmode
- match: (?i)#\+(END_SRC)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:source.lisp
- match: (?i)#\+(BEGIN_SRC)\s+(sh)\s*(.*)$
captures:
1: keyword.control.block.orgmode
2: constant.other.language.orgmode
3: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.shell.orgmode
- match: (?i)#\+(END_SRC)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:source.shell
- match: '(?i)#\+(BEGIN_(SRC|EXAMPLE))(?:\s+([\w-]+)?\s*(.*))?$'
captures:
1: keyword.control.block.orgmode
3: constant.other.language.orgmode
4: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.other.orgmode
- meta_content_scope: markup.raw.block.orgmode
- match: (?i)#\+(END_\2)$
captures:
1: keyword.control.block.orgmode
pop: true
- match: '#\+(OPTIONS):'
captures:
1: keyword.control.pragma.orgmode
push:
- meta_scope: meta.pragma.options.orgmode
- match: $
pop: true
- match: '([^\s]+):([^\s]+)'
scope: meta.option.orgmode
captures:
1: variable.parameter.option.orgmode
2: string.other.option.orgmode
- match: '#\+(CALL):\s+[A-Za-z-]+(?:\[([^\]]*)\])?\(?'
captures:
1: keyword.control.pragma.orgmode
2: string.other.header-args.orgmode
push:
- meta_scope: meta.pragma.call.orgmode
- match: '\)?([^)]*)$'
captures:
1: string.other.header-args.orgmode
pop: true
- match: (\w+)=
scope: meta.assignment.orgmode
captures:
1: variable.parameter.header-args.orgmode
- match: '^#\+([a-zA-Z_-]+): ?(.*)$'
scope: meta.pragma.orgmode
captures:
1: keyword.control.pragma.orgmode
2: string.unquoted.pragma.orgmode
- include: inline
heading-inline:
- match: ':([^:^\s]*)(?=:)'
scope: meta.keyword.orgmode
captures:
1: string.quoted.keyword.orgmode
- include: inline
inline:
- match: '(?<=^|[.,:;\s])/[^/]+/(?=$|[.,:;\s])'
scope: markup.italic.orgmode
- match: '(?<=^|[.,:;\s])\*[^*]+\*(?=$|[.,:;\s])'
scope: markup.bold.orgmode
- match: '(?<=^|[.,:;\s])_[^_]+_(?=$|[.,:;\s])'
scope: markup.underline.orgmode
- match: '(?<=^|[.,:;\s])([~=]).+?\1(?=$|[.,:;\s])'
scope: markup.raw.inline.orgmode
- match: '\[(?:\[([^\]]*)\])?\[([^\]]*)\]\]'
scope: meta.link.orgmode
captures:
1: markup.underline.link.orgmode
2: string.other.link.orgmode
- match: (?:http|ftp)s?:\/\/\S+
scope: markup.underline.url.orgmode
list-inline:
- match: '\[[ -X]\]'
scope: keyword.operator.checkbox.orgmode
- include: inline
properties:
- match: '^:([A-Za-z_]+):\s(.*)$'
scope: meta.property.orgmode
captures:
1: keyword.control.property.orgmode
2: string.unquoted.propval.orgmode
Vendored Submodule
+1
Vendored Submodule
+1
Submodule assets/syntaxes/Strace added at 3ec51e0bca
Vendored Submodule
+1
Submodule assets/syntaxes/Verilog added at 532e87c1b4
+149
View File
@@ -0,0 +1,149 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Verilog
file_extensions:
- v
- V
scope: source.verilog
contexts:
main:
- match: '^\s*(module|function|primitive)\s+\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
scope: meta.entity.module.verilog
captures:
1: storage.type.verilog
2: entity.name.type.class.verilog
- match: '^\s*(?!else)(?!begin)([a-zA-Z_][a-zA-Z0-9_]*)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*(\()'
scope: meta.definition.verilog
captures:
1: entity.name.type.class.verilog
2: entity.name.type.instance.verilog
3: keyword.operator.parenthesis.round.verilog
- match: '^\s*(?!else)(?!begin)([a-zA-Z_][a-zA-Z0-9_]*)\s+([#])(\()([ ._+`,a-zA-Z0-9]+)(\))\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*(\()'
scope: meta.definition.withparameter.verilog
captures:
1: entity.name.type.class.verilog
2: keyword.other.verilog
3: keyword.operator.parenthesis.round.verilog
4: keyword.other.verilog
5: keyword.operator.parenthesis.round.verilog
6: entity.name.type.instance.verilog
7: keyword.operator.parenthesis.round.verilog
- match: '^\s*\b(?!else)(?!begin)([a-zA-Z_][a-zA-Z0-9_]*)\b\s+([#])'
scope: meta.definition.withparameter.verilog
captures:
1: entity.name.type.class.verilog
2: keyword.other.verilog
- match: '^\s*(defparam)\s+([a-zA-Z_][a-zA-Z0-9_]*)(.[a-zA-Z_][a-zA-Z0-9_]*)\s*(=)'
scope: meta.definition.defparam.verilog
captures:
1: keyword.other.verilog
2: entity.name.type.instance.verilog
3: meta.module.parameters.verilog
4: keyword.other.verilog
- match: \b(automatic|cell|config|deassign|defparam|design|disable|edge|endconfig|endgenerate|endspecify|endtable|endtask|event|generate|genvar|ifnone|incdir|include|instance|liblist|library|localparam|macromodule|negedge|noshowcancelled|posedge|pulsestyle_onevent|pulsestyle_ondetect|real|realtime|scalared|showcancelled|specify|specparam|table|task|time|use|vectored)\b
scope: keyword.other.verilog
- match: "(#[0-9]+)"
scope: keyword.delay.verilog
- match: \b(initial|always|wait|force|release|assign)\b
scope: keyword.control.verilog
- match: \b(begin|end|fork|join)\b
scope: keyword.other.verilog
- match: \b(forever|repeat|while|for|if|else|case|casex|casez|default|endcase)\b
scope: keyword.control.verilog
- match: '^\s*(`include)\s+(["<].*[">])'
scope: meta.include.verilog
captures:
1: meta.preprocessor.verilog
2: entity.name.type.include.verilog
- match: '^\s*(`ifdef|`ifndef|`undef|`define)\s+([a-zA-Z_][a-zA-Z0-9_]*)\b'
scope: meta.preprocessor.ifdef.verilog
captures:
1: meta.preprocessor.verilog
2: constant.other.define.verilog
- match: '`(celldefine|default_nettype|define|else|elsif|endcelldefine|endif|ifdef|ifndef|include|line|nounconnected_drive|resetall|timescale|unconnected_drive|undef)\b'
scope: meta.preprocessor.verilog
- match: "[.][_a-zA-Z0-9]+"
scope: meta.module.parameters.verilog
- match: '`\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
scope: constant.other.define.verilog
- include: comments
- match: \b(endmodule|endfunction|endprimitive)\b
scope: storage.type.verilog
- match: '^\s*\b([a-zA-Z_][a-zA-Z0-9_]*)\b\s*(:)\s*'
scope: meta.case.verilog
captures:
1: entity.name.state.verilog
2: keyword.operator.bitwise.verilog
- include: all-types
- match: (==|===|!=|!==|<=|>=|<|>)
scope: keyword.operator.comparison.verilog
- match: (\-|\+|\*|\/|%)
scope: keyword.operator.arithmetic.verilog
- match: (!|&&|\|\|)
scope: keyword.operator.logical.verilog
- match: (&|\||\^|~|<<|>>|\?|:)
scope: keyword.operator.bitwise.verilog
- match: "({|})"
scope: keyword.operator.parenthesis.curly.verilog
- match: (\(|\))
scope: keyword.operator.parenthesis.round.verilog
- match: '(\[|\])'
scope: keyword.operator.parenthesis.square.verilog
- match: "([;,])"
scope: keyword.delimiter.verilog
- match: (#|@|=)
scope: keyword.other.verilog
- match: '\b(output|input|inout|and|nand|nor|or|xor|xnor|buf|not|bufif[01]|notif[01]|r?[npc]mos|tran|r?tranif[01]|pullup|pulldown)\b'
scope: support.type.verilog
- match: '((\b\d+)?''s?([bB]\s*(([0-1_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*))|[oO]\s*(([0-7_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*))|[dD]\s*(([0-9_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*))|[hH]\s*(([0-9a-fA-F_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*)))((e|E)(\+|-)?[0-9]+)?\b)|(\b\d+\b)'
scope: constant.numeric.verilog
- include: strings
- match: '\$\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
scope: support.function.verilog
all-types:
- include: storage-type-verilog
- include: storage-modifier-verilog
comments:
- match: /\*
captures:
0: punctuation.definition.comment.verilog
push:
- meta_scope: comment.block.verilog
- match: \*/
captures:
0: punctuation.definition.comment.verilog
pop: true
- match: (//).*$\n?
scope: comment.line.double-slash.verilog
captures:
1: punctuation.definition.comment.verilog
storage-modifier-verilog:
- match: '\b(signed|unsigned|small|medium|large|supply[01]|strong[01]|pull[01]|weak[01]|highz[01])\b'
scope: storage.modifier.verilog
storage-type-verilog:
- match: '\b(wire|tri|tri[01]|supply[01]|wand|triand|wor|trior|trireg|reg|parameter|integer)\b'
scope: storage.type.verilog
strings:
- match: '"'
captures:
0: punctuation.definition.string.begin.verilog
push:
- meta_scope: string.quoted.double.verilog
- match: '"'
captures:
0: punctuation.definition.string.end.verilog
pop: true
- match: \\.
scope: constant.character.escape.verilog
- match: "'"
captures:
0: punctuation.definition.string.begin.verilog
push:
- meta_scope: string.quoted.single.verilog
- match: "'"
captures:
0: punctuation.definition.string.end.verilog
pop: true
- match: \\.
scope: constant.character.escape.verilog
Vendored Submodule
+1
Submodule assets/syntaxes/hosts added at 21250a7117
+19
View File
@@ -0,0 +1,19 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: requirements.txt
file_extensions:
- requirements.txt
scope: source.requirementstxt
contexts:
main:
- match: (#).*$\n?
scope: comment.line.requirementstxt
captures:
1: punctuation.definition.comment.requirementstxt
- match: '(?i)^[a-z0-9_\-\.]+'
scope: string.package_name.requirementstxt
- match: (?i)==|<|<=|>=|>
scope: keyword.operator.logical.punctuation.requirementstxt
- match: '(?i)\d+\.[\da-z\-_\.]*'
scope: constant.numeric.verions.requirementstxt
+4
View File
@@ -25,3 +25,7 @@ contexts:
scope: entity.other.attribute-name.show-nonprintable.escape scope: entity.other.attribute-name.show-nonprintable.escape
- match: "␈" - match: "␈"
scope: entity.other.attribute-name.show-nonprintable.backspace scope: entity.other.attribute-name.show-nonprintable.backspace
- match: "\\\\x[A-Z0-9][A-Z0-9]"
scope: comment.block.show-nonprintable.backspace
- match: "\\\\u\\{[a-z0-9]+\\}"
scope: comment.block.show-nonprintable.backspace
Vendored Submodule
+1
+3
View File
@@ -107,6 +107,9 @@ make_deb() {
install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1" install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1" gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
# completions
install -Dm644 assets/completions/bat.fish "$tempdir/usr/share/fish/completions/$PROJECT_NAME.fish"
# readme and license # readme and license
install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md" install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"
install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT" install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"
+2 -1
View File
@@ -33,5 +33,6 @@ if [[ $TARGET == aarch64-unknown-linux-gnu ]]; then
sudo apt-get install -y \ sudo apt-get install -y \
gcc-4.8-aarch64-linux-gnu \ gcc-4.8-aarch64-linux-gnu \
binutils-aarch64-linux-gnu \ binutils-aarch64-linux-gnu \
gcc-aarch64-linux-gnu gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross
fi fi
+9 -1
View File
@@ -97,7 +97,7 @@ bat f - g # output 'f', then stdin, then 'g'.
最新の `.deb` パッケージを[こちら](https://github.com/sharkdp/bat/releases)からダウンロードして、インストールしてください: 最新の `.deb` パッケージを[こちら](https://github.com/sharkdp/bat/releases)からダウンロードして、インストールしてください:
``` bash ``` bash
sudo dpkg -i bat_0.11.0_amd64.deb # adapt version number and architecture sudo dpkg -i bat_0.12.0_amd64.deb # adapt version number and architecture
``` ```
### Arch Linux ### Arch Linux
@@ -124,6 +124,14 @@ xbps-install -S bat
dnf module install bat dnf module install bat
``` ```
### Gentoo Linux
[Gentoo Linuxの公式リソース](https://packages.gentoo.org/packages/sys-apps/bat)からインストールできます。
```bash
emerge sys-apps/bat
```
### FreeBSD ### FreeBSD
事前にコンパイル済みである[pkg](https://www.freshports.org/textproc/bat)をインストールできます: 事前にコンパイル済みである[pkg](https://www.freshports.org/textproc/bat)をインストールできます:
+59 -44
View File
@@ -10,27 +10,35 @@ bat [OPTIONS] [FILE]...
bat <SUBCOMMAND> bat <SUBCOMMAND>
.SH "OPTIONS" .SH "OPTIONS"
.HP .HP
General remarks
.IP
Command-line options like '-l'/'--language' that take values can be specified as
either '--language value', '--language=value', '-l value' or '-lvalue'.
.HP
\fB\-l\fR, \fB\-\-language\fR <language> \fB\-l\fR, \fB\-\-language\fR <language>
.IP .IP
Explicitly set the language for syntax highlighting. The language can be specified as a Explicitly set the language for syntax highlighting. The language can be
name (like 'C++' or 'LaTeX') or possible file extension (like 'cpp', 'hpp' or 'md'). Use specified as a name (like 'C++' or 'LaTeX') or possible file extension
\&'\-\-list\-languages' to show all supported language names and file extensions. (like 'cpp', 'hpp' or 'md'). Use '\-\-list\-languages' to show all supported
language names and file extensions.
.HP .HP
\fB\-\-list\-languages\fR \fB\-L\fR, \fB\-\-list\-languages\fR
.IP .IP
Display a list of supported languages for syntax highlighting. Display a list of supported languages for syntax highlighting.
.HP .HP
\fB\-m\fR, \fB\-\-map\-syntax\fR <from:to>... \fB\-m\fR, \fB\-\-map\-syntax\fR <from:to>...
.IP .IP
Map a file extension or file name to an existing syntax. For example, to highlight Map a file extension or file name to an existing syntax. For example, to
*.conf files with the INI syntax, use '\-m conf:ini'. To highlight files named highlight *.conf files with the INI syntax, use '\-m conf:ini'. To
\&'.myignore' with the Git Ignore syntax, use '\-m .myignore:gitignore'. highlight files named '.myignore' with the Git Ignore syntax, use '\-m
\&.myignore:gitignore'.
.HP .HP
\fB\-\-theme\fR <theme> \fB\-\-theme\fR <theme>
.IP .IP
Set the theme for syntax highlighting. Use '\-\-list\-themes' to see all available themes. Set the theme for syntax highlighting. Use '\-\-list\-themes' to see all
To set a default theme, add the '\-\-theme="..."' option to the configuration file or available themes. To set a default theme, add the '\-\-theme="..."' option
export the BAT_THEME environment variable (e.g.: export BAT_THEME="..."). to the configuration file or export the BAT_THEME environment variable
(e.g.: export BAT_THEME="...").
.HP .HP
\fB\-\-list\-themes\fR \fB\-\-list\-themes\fR
.IP .IP
@@ -38,27 +46,29 @@ Display a list of supported themes for syntax highlighting.
.HP .HP
\fB\-\-style\fR <style\-components> \fB\-\-style\fR <style\-components>
.IP .IP
Configure which elements (line numbers, file headers, grid borders, Git modifications, Configure which elements (line numbers, file headers, grid borders, Git
\&..) to display in addition to the file contents. The argument is a comma\-separated list modifications, ..) to display in addition to the file contents. The
of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full'). argument is a comma\-separated list of components to display (e.g.
To set a default style, add the '\-\-style=".."' option to the configuration file or \&'numbers,changes,grid') or a pre\-defined style ('full'). To set a default
export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible style, add the '\-\-style=".."' option to the configuration file or export
values: *auto*, full, plain, changes, header, grid, numbers. the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible
values: *auto*, full, plain, changes, header, grid, numbers, snip.
.HP .HP
\fB\-p\fR, \fB\-\-plain\fR \fB\-p\fR, \fB\-\-plain\fR
.IP .IP
Only show plain style, no decorations. This is an alias for '\-\-style=plain'. When '\-p' Only show plain style, no decorations. This is an alias for
is used twice ('\-pp'), it also disables automatic paging (alias for '\-\-style=plain \&'\-\-style=plain'. When '\-p' is used twice ('\-pp'), it also disables
\fB\-\-pager\fR=\fI\,never\/\fR'). automatic paging (alias for '\-\-style=plain \fB\-\-pager\fR=\fI\,never\/\fR').
.HP .HP
\fB\-n\fR, \fB\-\-number\fR \fB\-n\fR, \fB\-\-number\fR
.IP .IP
Only show line numbers, no other decorations. This is an alias for '\-\-style=numbers' Only show line numbers, no other decorations. This is an alias for
\&'\-\-style=numbers'
.HP .HP
\fB\-A\fR, \fB\-\-show\-all\fR \fB\-A\fR, \fB\-\-show\-all\fR
.IP .IP
Show non\-printable characters like space, tab or newline. Use '\-\-tabs' to control the Show non\-printable characters like space, tab or newline. Use '\-\-tabs' to
width of the tab\-placeholders. control the width of the tab\-placeholders.
.HP .HP
\fB\-r\fR, \fB\-\-line\-range\fR <N:M>... \fB\-r\fR, \fB\-\-line\-range\fR <N:M>...
.IP .IP
@@ -78,52 +88,57 @@ Highlight the N\-th line with a different background color
.HP .HP
\fB\-\-color\fR <when> \fB\-\-color\fR <when>
.IP .IP
Specify when to use colored output. The automatic mode only enables colors if an Specify when to use colored output. The automatic mode only enables colors
interactive terminal is detected. Possible values: *auto*, never, always. if an interactive terminal is detected. Possible values: *auto*, never,
always.
.HP .HP
\fB\-\-italic\-text\fR <when> \fB\-\-italic\-text\fR <when>
.IP .IP
Specify when to use ANSI sequences for italic text in the output. Possible values: Specify when to use ANSI sequences for italic text in the output. Possible
always, *never*. values: always, *never*.
.HP .HP
\fB\-\-decorations\fR <when> \fB\-\-decorations\fR <when>
.IP .IP
Specify when to use the decorations that have been specified via '\-\-style'. The Specify when to use the decorations that have been specified via
automatic mode only enables decorations if an interactive terminal is detected. Possible \&'\-\-style'. The automatic mode only enables decorations if an interactive
values: *auto*, never, always. terminal is detected. Possible values: *auto*, never, always.
.HP .HP
\fB\-\-paging\fR <when> \fB\-\-paging\fR <when>
.IP .IP
Specify when to use the pager. To control which pager is used, set the PAGER or Specify when to use the pager. To control which pager is used, set the
BAT_PAGER environment variables (the latter takes precedence) or use the '\-\-pager' PAGER or BAT_PAGER environment variables (the latter takes precedence) or
option. To disable the pager permanently, set BAT_PAGER to an empty string or set use the '\-\-pager' option. To disable the pager permanently, set BAT_PAGER
\&'\-\-paging=never' in the configuration file. Possible values: *auto*, never, always. to an empty string or set '\-\-paging=never' in the configuration file.
Possible values: *auto*, never, always.
.HP .HP
\fB\-\-pager\fR <command> \fB\-\-pager\fR <command>
.IP .IP
Determine which pager is used. This option will overwrite the PAGER and BAT_PAGER Determine which pager is used. This option will overwrite the PAGER and
environment variables. The default pager is 'less'. To disable the pager completely, use BAT_PAGER environment variables. The default pager is 'less'. To disable
the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'. the pager completely, use the '\-\-paging' option. Example: '\-\-pager "less
\fB\-RF\fR"'.
.HP .HP
\fB\-\-wrap\fR <mode> \fB\-\-wrap\fR <mode>
.IP .IP
Specify the text\-wrapping mode (*auto*, never, character). The '\-\-terminal\-width' option Specify the text\-wrapping mode (*auto*, never, character). The
can be used in addition to control the output width. \&'\-\-terminal\-width' option can be used in addition to control the output
width.
.HP .HP
\fB\-\-tabs\fR <T> \fB\-\-tabs\fR <T>
.IP .IP
Set the tab width to T spaces. Use a width of 0 to pass tabs through directly Set the tab width to T spaces. Use a width of 0 to pass tabs through
directly
.HP .HP
\fB\-u\fR, \fB\-\-unbuffered\fR \fB\-u\fR, \fB\-\-unbuffered\fR
.IP .IP
This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered'). The output is This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered').
always unbuffered \- this option is simply ignored. The output is always unbuffered \- this option is simply ignored.
.HP .HP
\fB\-\-terminal\-width\fR <width> \fB\-\-terminal\-width\fR <width>
.IP .IP
Explicitly set the width of the terminal instead of determining it automatically. If Explicitly set the width of the terminal instead of determining it
prefixed with '+' or '\-', the value will be treated as an offset to the actual terminal automatically. If prefixed with '+' or '\-', the value will be treated as
width. See also: '\-\-wrap'. an offset to the actual terminal width. See also: '\-\-wrap'.
.HP .HP
\fB\-h\fR, \fB\-\-help\fR \fB\-h\fR, \fB\-\-help\fR
.IP .IP
+1 -1
View File
@@ -117,7 +117,7 @@ impl HighlightingAssets {
pub fn save(&self, dir: Option<&Path>) -> Result<()> { pub fn save(&self, dir: Option<&Path>) -> Result<()> {
let target_dir = dir.unwrap_or_else(|| PROJECT_DIRS.cache_dir()); let target_dir = dir.unwrap_or_else(|| PROJECT_DIRS.cache_dir());
let _ = fs::create_dir(target_dir); let _ = fs::create_dir_all(target_dir);
let theme_set_path = target_dir.join("themes.bin"); let theme_set_path = target_dir.join("themes.bin");
let syntax_set_path = target_dir.join("syntaxes.bin"); let syntax_set_path = target_dir.join("syntaxes.bin");
+8 -4
View File
@@ -19,6 +19,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.global_setting(AppSettings::UnifiedHelpMessage) .global_setting(AppSettings::UnifiedHelpMessage)
.global_setting(AppSettings::HidePossibleValuesInHelp) .global_setting(AppSettings::HidePossibleValuesInHelp)
.setting(AppSettings::ArgsNegateSubcommands) .setting(AppSettings::ArgsNegateSubcommands)
.setting(AppSettings::AllowExternalSubcommands)
.setting(AppSettings::DisableHelpSubcommand) .setting(AppSettings::DisableHelpSubcommand)
.setting(AppSettings::VersionlessSubcommands) .setting(AppSettings::VersionlessSubcommands)
.max_term_width(100) .max_term_width(100)
@@ -54,6 +55,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.arg( .arg(
Arg::with_name("list-languages") Arg::with_name("list-languages")
.long("list-languages") .long("list-languages")
.short("L")
.conflicts_with("list-themes") .conflicts_with("list-themes")
.help("Display all supported languages.") .help("Display all supported languages.")
.long_help("Display a list of supported languages for syntax highlighting."), .long_help("Display a list of supported languages for syntax highlighting."),
@@ -110,7 +112,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.validator(|val| { .validator(|val| {
let mut invalid_vals = val.split(',').filter(|style| { let mut invalid_vals = val.split(',').filter(|style| {
!&[ !&[
"auto", "full", "plain", "changes", "header", "grid", "numbers", "auto", "full", "plain", "changes", "header", "grid", "numbers", "snip"
] ]
.contains(style) .contains(style)
}); });
@@ -123,7 +125,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
}) })
.help( .help(
"Comma-separated list of style elements to display \ "Comma-separated list of style elements to display \
(*auto*, full, plain, changes, header, grid, numbers).", (*auto*, full, plain, changes, header, grid, numbers, snip).",
) )
.long_help( .long_help(
"Configure which elements (line numbers, file headers, grid \ "Configure which elements (line numbers, file headers, grid \
@@ -133,7 +135,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
pre-defined style ('full'). To set a default style, add the \ pre-defined style ('full'). To set a default style, add the \
'--style=\"..\"' option to the configuration file or export the \ '--style=\"..\"' option to the configuration file or export the \
BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\"). \ BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\"). \
Possible values: *auto*, full, plain, changes, header, grid, numbers.", Possible values: *auto*, full, plain, changes, header, grid, numbers, snip.",
), ),
) )
.arg( .arg(
@@ -170,7 +172,8 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.help("Show non-printable characters (space, tab, newline, ..).") .help("Show non-printable characters (space, tab, newline, ..).")
.long_help( .long_help(
"Show non-printable characters like space, tab or newline. \ "Show non-printable characters like space, tab or newline. \
Use '--tabs' to control the width of the tab-placeholders.", This option can also be used to print binary files. \
Use '--tabs' to control the width of the tab-placeholders."
), ),
) )
.arg( .arg(
@@ -332,6 +335,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.takes_value(true) .takes_value(true)
.value_name("width") .value_name("width")
.hidden_short_help(true) .hidden_short_help(true)
.allow_hyphen_values(true)
.validator( .validator(
|t| { |t| {
let is_offset = t.starts_with('+') || t.starts_with('-'); let is_offset = t.starts_with('+') || t.starts_with('-');
+17 -2
View File
@@ -76,7 +76,7 @@ impl<'b> Controller<'b> {
&self, &self,
reader: InputFileReader, reader: InputFileReader,
printer: &mut P, printer: &mut P,
writer: &mut Write, writer: &mut dyn Write,
input_file: InputFile<'a>, input_file: InputFile<'a>,
) -> Result<()> { ) -> Result<()> {
printer.print_header(writer, input_file)?; printer.print_header(writer, input_file)?;
@@ -91,21 +91,36 @@ impl<'b> Controller<'b> {
fn print_file_ranges<P: Printer>( fn print_file_ranges<P: Printer>(
&self, &self,
printer: &mut P, printer: &mut P,
writer: &mut Write, writer: &mut dyn Write,
mut reader: InputFileReader, mut reader: InputFileReader,
line_ranges: &LineRanges, line_ranges: &LineRanges,
) -> Result<()> { ) -> Result<()> {
let mut line_buffer = Vec::new(); let mut line_buffer = Vec::new();
let mut line_number: usize = 1; let mut line_number: usize = 1;
let mut first_range: bool = true;
let mut mid_range: bool = false;
while reader.read_line(&mut line_buffer)? { while reader.read_line(&mut line_buffer)? {
match line_ranges.check(line_number) { match line_ranges.check(line_number) {
RangeCheckResult::OutsideRange => { RangeCheckResult::OutsideRange => {
// Call the printer in case we need to call the syntax highlighter // Call the printer in case we need to call the syntax highlighter
// for this line. However, set `out_of_range` to `true`. // for this line. However, set `out_of_range` to `true`.
printer.print_line(true, writer, line_number, &line_buffer)?; printer.print_line(true, writer, line_number, &line_buffer)?;
mid_range = false;
} }
RangeCheckResult::InRange => { RangeCheckResult::InRange => {
if self.config.output_components.snip() {
if first_range {
first_range = false;
mid_range = true;
} else if !mid_range {
mid_range = true;
printer.print_snip(writer)?;
}
}
printer.print_line(false, writer, line_number, &line_buffer)?; printer.print_line(false, writer, line_number, &line_buffer)?;
} }
RangeCheckResult::AfterLastRange => { RangeCheckResult::AfterLastRange => {
+1 -1
View File
@@ -98,7 +98,7 @@ impl OutputType {
OutputType::Stdout(io::stdout()) OutputType::Stdout(io::stdout())
} }
pub fn handle(&mut self) -> Result<&mut Write> { pub fn handle(&mut self) -> Result<&mut dyn Write> {
Ok(match *self { Ok(match *self {
OutputType::Pager(ref mut command) => command OutputType::Pager(ref mut command) => command
.stdin .stdin
+101 -27
View File
@@ -33,41 +33,115 @@ pub fn expand_tabs(line: &str, width: usize, cursor: &mut usize) -> String {
buffer buffer
} }
pub fn replace_nonprintable(input: &str, tab_width: usize) -> String { fn try_parse_utf8_char(input: &[u8]) -> Option<(char, usize)> {
let str_from_utf8 = |seq| std::str::from_utf8(seq).ok();
let decoded = None
.or(input.get(0..1).and_then(str_from_utf8).map(|c| (c, 1)))
.or(input.get(0..2).and_then(str_from_utf8).map(|c| (c, 2)))
.or(input.get(0..3).and_then(str_from_utf8).map(|c| (c, 3)))
.or(input.get(0..4).and_then(str_from_utf8).map(|c| (c, 4)));
let decoded_char = decoded.map(|(seq, n)| (seq.chars().next().unwrap(), n));
decoded_char
}
pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {
let mut output = String::new(); let mut output = String::new();
let tab_width = if tab_width == 0 { 4 } else { tab_width }; let tab_width = if tab_width == 0 { 4 } else { tab_width };
for chr in input.chars() { let mut idx = 0;
match chr { let len = input.len();
// space while idx < len {
' ' => output.push('•'), if let Some((chr, skip_ahead)) = try_parse_utf8_char(&input[idx..]) {
// tab idx += skip_ahead;
'\t' => {
if tab_width == 1 { match chr {
output.push('↹'); // space
} else { ' ' => output.push('•'),
output.push('├'); // tab
output.push_str(&"".repeat(tab_width - 2)); '\t' => {
output.push('┤'); if tab_width == 1 {
output.push('↹');
} else {
output.push('├');
output.push_str(&"".repeat(tab_width - 2));
output.push('┤');
}
} }
// line feed
'\x0A' => output.push('␊'),
// carriage return
'\x0D' => output.push('␍'),
// null
'\x00' => output.push('␀'),
// bell
'\x07' => output.push('␇'),
// backspace
'\x08' => output.push('␈'),
// escape
'\x1B' => output.push('␛'),
// printable ASCII
c if c.is_ascii_alphanumeric()
|| c.is_ascii_punctuation()
|| c.is_ascii_graphic() =>
{
output.push(c)
}
// everything else
c => output.push_str(&c.escape_unicode().collect::<String>()),
} }
// line feed } else {
'\x0A' => output.push('␊'), output.push_str(&format!("\\x{:02X}", input[idx]));
// carriage return idx += 1;
'\x0D' => output.push('␍'),
// null
'\x00' => output.push('␀'),
// bell
'\x07' => output.push('␇'),
// backspace
'\x08' => output.push('␈'),
// escape
'\x1B' => output.push('␛'),
// anything else
_ => output.push(chr),
} }
} }
output output
} }
#[test]
fn test_try_parse_utf8_char() {
assert_eq!(try_parse_utf8_char(&[0x20]), Some((' ', 1)));
assert_eq!(try_parse_utf8_char(&[0x20, 0x20]), Some((' ', 1)));
assert_eq!(try_parse_utf8_char(&[0x20, 0xef]), Some((' ', 1)));
assert_eq!(try_parse_utf8_char(&[0x00]), Some(('\x00', 1)));
assert_eq!(try_parse_utf8_char(&[0x1b]), Some(('\x1b', 1)));
assert_eq!(try_parse_utf8_char(&[0xc3, 0xa4]), Some(('ä', 2)));
assert_eq!(try_parse_utf8_char(&[0xc3, 0xa4, 0xef]), Some(('ä', 2)));
assert_eq!(try_parse_utf8_char(&[0xc3, 0xa4, 0x20]), Some(('ä', 2)));
assert_eq!(try_parse_utf8_char(&[0xe2, 0x82, 0xac]), Some(('€', 3)));
assert_eq!(
try_parse_utf8_char(&[0xe2, 0x82, 0xac, 0xef]),
Some(('€', 3))
);
assert_eq!(
try_parse_utf8_char(&[0xe2, 0x82, 0xac, 0x20]),
Some(('€', 3))
);
assert_eq!(try_parse_utf8_char(&[0xe2, 0x88, 0xb0]), Some(('∰', 3)));
assert_eq!(
try_parse_utf8_char(&[0xf0, 0x9f, 0x8c, 0x82]),
Some(('🌂', 4))
);
assert_eq!(
try_parse_utf8_char(&[0xf0, 0x9f, 0x8c, 0x82, 0xef]),
Some(('🌂', 4))
);
assert_eq!(
try_parse_utf8_char(&[0xf0, 0x9f, 0x8c, 0x82, 0x20]),
Some(('🌂', 4))
);
assert_eq!(try_parse_utf8_char(&[]), None);
assert_eq!(try_parse_utf8_char(&[0xef]), None);
assert_eq!(try_parse_utf8_char(&[0xef, 0x20]), None);
assert_eq!(try_parse_utf8_char(&[0xf0, 0xf0]), None);
}
+87 -29
View File
@@ -30,12 +30,15 @@ use crate::style::OutputWrap;
use crate::terminal::{as_terminal_escaped, to_ansi_color}; use crate::terminal::{as_terminal_escaped, to_ansi_color};
pub trait Printer { pub trait Printer {
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>; fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
fn print_footer(&mut self, handle: &mut Write) -> Result<()>; fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()>;
fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>;
fn print_line( fn print_line(
&mut self, &mut self,
out_of_range: bool, out_of_range: bool,
handle: &mut Write, handle: &mut dyn Write,
line_number: usize, line_number: usize,
line_buffer: &[u8], line_buffer: &[u8],
) -> Result<()>; ) -> Result<()>;
@@ -50,18 +53,22 @@ impl SimplePrinter {
} }
impl Printer for SimplePrinter { impl Printer for SimplePrinter {
fn print_header(&mut self, _handle: &mut Write, _file: InputFile) -> Result<()> { fn print_header(&mut self, _handle: &mut dyn Write, _file: InputFile) -> Result<()> {
Ok(()) Ok(())
} }
fn print_footer(&mut self, _handle: &mut Write) -> Result<()> { fn print_footer(&mut self, _handle: &mut dyn Write) -> Result<()> {
Ok(())
}
fn print_snip(&mut self, _handle: &mut dyn Write) -> Result<()> {
Ok(()) Ok(())
} }
fn print_line( fn print_line(
&mut self, &mut self,
out_of_range: bool, out_of_range: bool,
handle: &mut Write, handle: &mut dyn Write,
_line_number: usize, _line_number: usize,
line_buffer: &[u8], line_buffer: &[u8],
) -> Result<()> { ) -> Result<()> {
@@ -134,7 +141,10 @@ impl<'a> InteractivePrinter<'a> {
let mut line_changes = None; let mut line_changes = None;
let highlighter = if reader.content_type.map_or(false, |c| c.is_binary()) { let highlighter = if reader
.content_type
.map_or(false, |c| c.is_binary() && !config.show_nonprintable)
{
None None
} else { } else {
// Get the Git modifications // Get the Git modifications
@@ -166,7 +176,7 @@ impl<'a> InteractivePrinter<'a> {
} }
} }
fn print_horizontal_line(&mut self, handle: &mut Write, grid_char: char) -> Result<()> { fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
if self.panel_width == 0 { if self.panel_width == 0 {
writeln!( writeln!(
handle, handle,
@@ -182,6 +192,24 @@ impl<'a> InteractivePrinter<'a> {
Ok(()) Ok(())
} }
fn create_fake_panel(&self, text: &str) -> String {
if self.panel_width == 0 {
"".to_string()
} else {
let text_truncated: String = text.chars().take(self.panel_width - 1).collect();
let text_filled: String = format!(
"{}{}",
text_truncated,
" ".repeat(self.panel_width - 1 - text_truncated.len())
);
if self.config.output_components.grid() {
format!("{}", text_filled)
} else {
format!("{}", text_filled)
}
}
}
fn preprocess(&self, text: &str, cursor: &mut usize) -> String { fn preprocess(&self, text: &str, cursor: &mut usize) -> String {
if self.config.tab_width > 0 { if self.config.tab_width > 0 {
expand_tabs(text, self.config.tab_width, cursor) expand_tabs(text, self.config.tab_width, cursor)
@@ -192,9 +220,9 @@ impl<'a> InteractivePrinter<'a> {
} }
impl<'a> Printer for InteractivePrinter<'a> { impl<'a> Printer for InteractivePrinter<'a> {
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()> { fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()> {
if !self.config.output_components.header() { if !self.config.output_components.header() {
if Some(ContentType::BINARY) == self.content_type { if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
let input = match file { let input = match file {
InputFile::Ordinary(filename) => format!("file '{}'", filename), InputFile::Ordinary(filename) => format!("file '{}'", filename),
_ => "STDIN".into(), _ => "STDIN".into(),
@@ -203,10 +231,15 @@ impl<'a> Printer for InteractivePrinter<'a> {
writeln!( writeln!(
handle, handle,
"{}: Binary content from {} will not be printed to the terminal \ "{}: Binary content from {} will not be printed to the terminal \
(but will be present if the output of 'bat' is piped).", (but will be present if the output of 'bat' is piped). You can use 'bat -A' \
to show the binary file contents.",
Yellow.paint("[bat warning]"), Yellow.paint("[bat warning]"),
input input
)?; )?;
} else {
if self.config.output_components.grid() {
self.print_horizontal_line(handle, '┬')?;
}
} }
return Ok(()); return Ok(());
} }
@@ -248,7 +281,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
)?; )?;
if self.config.output_components.grid() { if self.config.output_components.grid() {
if self.content_type.map_or(false, |c| c.is_text()) { if self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable {
self.print_horizontal_line(handle, '┼')?; self.print_horizontal_line(handle, '┼')?;
} else { } else {
self.print_horizontal_line(handle, '┴')?; self.print_horizontal_line(handle, '┴')?;
@@ -258,8 +291,9 @@ impl<'a> Printer for InteractivePrinter<'a> {
Ok(()) Ok(())
} }
fn print_footer(&mut self, handle: &mut Write) -> Result<()> { fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()> {
if self.config.output_components.grid() && self.content_type.map_or(false, |c| c.is_text()) if self.config.output_components.grid()
&& (self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable)
{ {
self.print_horizontal_line(handle, '┴') self.print_horizontal_line(handle, '┴')
} else { } else {
@@ -267,30 +301,54 @@ impl<'a> Printer for InteractivePrinter<'a> {
} }
} }
fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()> {
let panel = self.create_fake_panel(" ...");
let panel_count = panel.chars().count();
let title = "8<";
let title_count = title.chars().count();
let snip_left = "".repeat((self.config.term_width - panel_count - (title_count / 2)) / 4);
let snip_left_count = snip_left.chars().count(); // Can't use .len() with Unicode.
let snip_right =
"".repeat((self.config.term_width - panel_count - snip_left_count - title_count) / 2);
write!(
handle,
"{}\n",
self.colors
.grid
.paint(format!("{}{}{}{}", panel, snip_left, title, snip_right))
)?;
Ok(())
}
fn print_line( fn print_line(
&mut self, &mut self,
out_of_range: bool, out_of_range: bool,
handle: &mut Write, handle: &mut dyn Write,
line_number: usize, line_number: usize,
line_buffer: &[u8], line_buffer: &[u8],
) -> Result<()> { ) -> Result<()> {
let mut line = match self.content_type { let line = if self.config.show_nonprintable {
Some(ContentType::BINARY) | None => { replace_nonprintable(&line_buffer, self.config.tab_width)
return Ok(()); } else {
match self.content_type {
Some(ContentType::BINARY) | None => {
return Ok(());
}
Some(ContentType::UTF_16LE) => UTF_16LE
.decode(&line_buffer, DecoderTrap::Replace)
.map_err(|_| "Invalid UTF-16LE")?,
Some(ContentType::UTF_16BE) => UTF_16BE
.decode(&line_buffer, DecoderTrap::Replace)
.map_err(|_| "Invalid UTF-16BE")?,
_ => String::from_utf8_lossy(&line_buffer).to_string(),
} }
Some(ContentType::UTF_16LE) => UTF_16LE
.decode(&line_buffer, DecoderTrap::Replace)
.map_err(|_| "Invalid UTF-16LE")?,
Some(ContentType::UTF_16BE) => UTF_16BE
.decode(&line_buffer, DecoderTrap::Replace)
.map_err(|_| "Invalid UTF-16BE")?,
_ => String::from_utf8_lossy(&line_buffer).to_string(),
}; };
if self.config.show_nonprintable {
line = replace_nonprintable(&line, self.config.tab_width);
}
let regions = { let regions = {
let highlighter = match self.highlighter { let highlighter = match self.highlighter {
Some(ref mut highlighter) => highlighter, Some(ref mut highlighter) => highlighter,
+8
View File
@@ -10,6 +10,7 @@ pub enum OutputComponent {
Grid, Grid,
Header, Header,
Numbers, Numbers,
Snip,
Full, Full,
Plain, Plain,
} }
@@ -34,11 +35,13 @@ impl OutputComponent {
OutputComponent::Grid => &[OutputComponent::Grid], OutputComponent::Grid => &[OutputComponent::Grid],
OutputComponent::Header => &[OutputComponent::Header], OutputComponent::Header => &[OutputComponent::Header],
OutputComponent::Numbers => &[OutputComponent::Numbers], OutputComponent::Numbers => &[OutputComponent::Numbers],
OutputComponent::Snip => &[OutputComponent::Snip],
OutputComponent::Full => &[ OutputComponent::Full => &[
OutputComponent::Changes, OutputComponent::Changes,
OutputComponent::Grid, OutputComponent::Grid,
OutputComponent::Header, OutputComponent::Header,
OutputComponent::Numbers, OutputComponent::Numbers,
OutputComponent::Snip,
], ],
OutputComponent::Plain => &[], OutputComponent::Plain => &[],
} }
@@ -55,6 +58,7 @@ impl FromStr for OutputComponent {
"grid" => Ok(OutputComponent::Grid), "grid" => Ok(OutputComponent::Grid),
"header" => Ok(OutputComponent::Header), "header" => Ok(OutputComponent::Header),
"numbers" => Ok(OutputComponent::Numbers), "numbers" => Ok(OutputComponent::Numbers),
"snip" => Ok(OutputComponent::Snip),
"full" => Ok(OutputComponent::Full), "full" => Ok(OutputComponent::Full),
"plain" => Ok(OutputComponent::Plain), "plain" => Ok(OutputComponent::Plain),
_ => Err(format!("Unknown style '{}'", s).into()), _ => Err(format!("Unknown style '{}'", s).into()),
@@ -82,6 +86,10 @@ impl OutputComponents {
self.0.contains(&OutputComponent::Numbers) self.0.contains(&OutputComponent::Numbers)
} }
pub fn snip(&self) -> bool {
self.0.contains(&OutputComponent::Snip)
}
pub fn plain(&self) -> bool { pub fn plain(&self) -> bool {
self.0.iter().all(|c| c == &OutputComponent::Plain) self.0.iter().all(|c| c == &OutputComponent::Plain)
} }
+1
View File
@@ -0,0 +1 @@
test
+31 -1
View File
@@ -451,7 +451,7 @@ fn utf16() {
#[test] #[test]
fn can_print_file_named_cache() { fn can_print_file_named_cache() {
bat() bat_with_config()
.arg("cache") .arg("cache")
.assert() .assert()
.success() .success()
@@ -459,7 +459,37 @@ fn can_print_file_named_cache() {
.stderr(""); .stderr("");
} }
#[test]
fn can_print_file_starting_with_cache() {
bat_with_config()
.arg("cache.c")
.assert()
.success()
.stdout("test\n")
.stderr("");
}
#[test] #[test]
fn does_not_print_unwanted_file_named_cache() { fn does_not_print_unwanted_file_named_cache() {
bat_with_config().arg("cach").assert().failure(); bat_with_config().arg("cach").assert().failure();
} }
#[test]
fn snip() {
bat()
.arg("multiline.txt")
.arg("--style=numbers,snip")
.arg("--decorations=always")
.arg("--line-range=1:2")
.arg("--line-range=4:")
.arg("--terminal-width=80")
.assert()
.success()
.stdout(
" 1 line 1
2 line 2
...─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 8< ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
4 line 4
",
);
}
@@ -1,3 +1,4 @@
──┬─────────────────────────────────────────────────────────────────────────────
│ struct Rectangle { │ struct Rectangle {
│ width: u32, │ width: u32,
│ height: u32, │ height: u32,
@@ -1,3 +1,4 @@
───────┬────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle { 1 │ struct Rectangle {
2 │ width: u32, 2 │ width: u32,
3 │ height: u32, 3 │ height: u32,
+1
View File
@@ -1,3 +1,4 @@
────────────────────────────────────────────────────────────────────────────────
struct Rectangle { struct Rectangle {
width: u32, width: u32,
height: u32, height: u32,
@@ -1,3 +1,4 @@
─────┬──────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle { 1 │ struct Rectangle {
2 │ width: u32, 2 │ width: u32,
3 │ height: u32, 3 │ height: u32,