Skip to content

Commit b089890

Browse files
authored
Syntax: add cmd-help (#2148)
* Add cmd-help syntax To highlight command --help messages. * README.md: mention help message highlighting * README.md: edit help message highlighting
1 parent 3239d3b commit b089890

File tree

6 files changed

+133
-0
lines changed

6 files changed

+133
-0
lines changed

.gitmodules

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,8 @@
239239
[submodule "assets/syntaxes/02_Extra/SublimeJQ"]
240240
path = assets/syntaxes/02_Extra/SublimeJQ
241241
url = https://github.com/zogwarg/SublimeJQ.git
242+
[submodule "assets/syntaxes/02_Extra/cmd-help"]
243+
path = assets/syntaxes/02_Extra/cmd-help
244+
url = https://github.com/victor-gp/cmd-help-sublime-syntax.git
245+
branch = main
246+
shallow = true

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
- Mapped clang-format config file (.clang-format) to YAML syntax (@TruncatedDinosour)
1818
- log syntax: improved handling of escape characters in double quoted strings. See #2123 (@keith-hall)
19+
- Added cmd-help syntax to scope --help messages. See #2148 (@victor-gp)
1920

2021
## Themes
2122

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@ Also, note that this will [not work](https://github.com/sharkdp/bat/issues/1145)
212212

213213
The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.md) script is a wrapper that will format code and print it with `bat`.
214214

215+
#### Highlighting `--help` messages
216+
217+
You can use `bat` to colorize help text: `$ cp --help | bat -plhelp`
218+
219+
You can also use a wrapper around this:
220+
221+
```bash
222+
# in your .bashrc/.zshrc/*rc
223+
alias bathelp='bat --plain --language=help'
224+
help() {
225+
"$@" --help 2>&1 | bathelp
226+
}
227+
```
228+
229+
Then you can do `$ help cp` or `$ help git commit`.
230+
231+
Please report any issues with the help syntax in [this repository](https://github.com/victor-gp/cmd-help-sublime-syntax).
232+
215233

216234
## Installation
217235

assets/syntaxes/02_Extra/cmd-help

Submodule cmd-help added at 1e513f5
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
bat 0.20.0 (e735562-modified)
2+
A cat(1) clone with syntax highlighting and Git integration.
3+
4+
USAGE:
5+
 bat [OPTIONS] [FILE]...
6+
 bat <SUBCOMMAND>
7+
8+
OPTIONS:
9+
 -A, --show-all
10+
 Show non-printable characters (space, tab, newline, ..).
11+
12+
 -p, --plain Show plain style (alias for '--style=plain').
13+
 -l, --language <language> Set the language for syntax highlighting.
14+
 -H, --highlight-line <N:M>... Highlight lines N through M.
15+
 --file-name <name>... Specify the name to display for a file.
16+
 -d, --diff
17+
 Only show lines that have been added/removed/modified.
18+
19+
 --tabs <T> Set the tab width to T spaces.
20+
 --wrap <mode>
21+
 Specify the text-wrapping mode (*auto*, never, character).
22+
23+
 -n, --number
24+
 Show line numbers (alias for '--style=numbers').
25+
26+
 --color <when> When to use colors (*auto*, never, always).
27+
 --italic-text <when> Use italics in output (always, *never*)
28+
 --decorations <when>
29+
 When to show the decorations (*auto*, never, always).
30+
31+
 --paging <when>
32+
 Specify when to use the pager, or use `-P` to disable (*auto*, never,
33+
 always).
34+
 -m, --map-syntax <glob:syntax>...
35+
 Use the specified syntax for files matching the glob pattern
36+
 ('*.cpp:C++').
37+
 --theme <theme> Set the color theme for syntax highlighting.
38+
 --list-themes Display all supported highlighting themes.
39+
 --style <components>
40+
 Comma-separated list of style elements to display (*auto*, full, plain,
41+
 changes, header, grid, rule, numbers, snip).
42+
 -r, --line-range <N:M>... Only print the lines from N to M.
43+
 -L, --list-languages Display all supported languages.
44+
 -h, --help Print this help message.
45+
 -V, --version Show version information.
46+
47+
ARGS:
48+
 <FILE>... File(s) to print / concatenate. Use '-' for standard input.
49+
50+
SUBCOMMANDS:
51+
 cache Modify the syntax-definition and theme cache
52+
53+
Note: `bat -h` prints a short and concise overview while `bat --help` gives all
54+
details.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
bat 0.20.0 (e735562-modified)
2+
A cat(1) clone with syntax highlighting and Git integration.
3+
4+
USAGE:
5+
bat [OPTIONS] [FILE]...
6+
bat <SUBCOMMAND>
7+
8+
OPTIONS:
9+
-A, --show-all
10+
Show non-printable characters (space, tab, newline, ..).
11+
12+
-p, --plain Show plain style (alias for '--style=plain').
13+
-l, --language <language> Set the language for syntax highlighting.
14+
-H, --highlight-line <N:M>... Highlight lines N through M.
15+
--file-name <name>... Specify the name to display for a file.
16+
-d, --diff
17+
Only show lines that have been added/removed/modified.
18+
19+
--tabs <T> Set the tab width to T spaces.
20+
--wrap <mode>
21+
Specify the text-wrapping mode (*auto*, never, character).
22+
23+
-n, --number
24+
Show line numbers (alias for '--style=numbers').
25+
26+
--color <when> When to use colors (*auto*, never, always).
27+
--italic-text <when> Use italics in output (always, *never*)
28+
--decorations <when>
29+
When to show the decorations (*auto*, never, always).
30+
31+
--paging <when>
32+
Specify when to use the pager, or use `-P` to disable (*auto*, never,
33+
always).
34+
-m, --map-syntax <glob:syntax>...
35+
Use the specified syntax for files matching the glob pattern
36+
('*.cpp:C++').
37+
--theme <theme> Set the color theme for syntax highlighting.
38+
--list-themes Display all supported highlighting themes.
39+
--style <components>
40+
Comma-separated list of style elements to display (*auto*, full, plain,
41+
changes, header, grid, rule, numbers, snip).
42+
-r, --line-range <N:M>... Only print the lines from N to M.
43+
-L, --list-languages Display all supported languages.
44+
-h, --help Print this help message.
45+
-V, --version Show version information.
46+
47+
ARGS:
48+
<FILE>... File(s) to print / concatenate. Use '-' for standard input.
49+
50+
SUBCOMMANDS:
51+
cache Modify the syntax-definition and theme cache
52+
53+
Note: `bat -h` prints a short and concise overview while `bat --help` gives all
54+
details.

0 commit comments

Comments
 (0)