summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan P. <eth-p+git@hidden.email>2024-04-06 15:04:20 -0700
committerEthan P. <eth-p+git@hidden.email>2024-07-30 21:21:55 -0700
commit6e91ba83b7663d22f88788d89595513e55b4ec0f (patch)
treecd6de1e56d1c198c98940ae022850a48c1ba1f4e
parentb74c125c43bb28e0b2b8f5188dac5d7348deae95 (diff)
Update clap/docs for merging `--style` arguments
-rw-r--r--README.md10
-rw-r--r--doc/long-help.txt6
-rw-r--r--src/bin/bat/clap_app.rs6
3 files changed, 22 insertions, 0 deletions
diff --git a/README.md b/README.md
index 1e42e501..016fe834 100644
--- a/README.md
+++ b/README.md
@@ -515,6 +515,16 @@ and line numbers but no grid and no file header. Set the `BAT_STYLE` environment
variable to make these changes permanent or use `bat`s
[configuration file](https://github.com/sharkdp/bat#configuration-file).
+>[!tip]
+> If you specify a default style in `bat`'s config file, you can change which components
+> are displayed during a single run of `bat` using the `--style` command-line argument.
+> By prefixing a component with `+` or `-`, it can be added or removed from the current style.
+>
+> For example, if your config contains `--style=full,-snip`, you can run bat with
+> `--style=-grid,+snip` to remove the grid and add back the `snip` component.
+> Or, if you want to override the styles completely, you use `--style=numbers` to
+> only show the line numbers.
+
### Adding new syntaxes / language definitions
Should you find that a particular syntax is not available within `bat`, you can follow these
diff --git a/doc/long-help.txt b/doc/long-help.txt
index d9cdce39..2b03490f 100644
--- a/doc/long-help.txt
+++ b/doc/long-help.txt
@@ -134,6 +134,12 @@ Options:
set a default style, add the '--style=".."' option to the configuration file or export the
BAT_STYLE environment variable (e.g.: export BAT_STYLE="..").
+ When styles are specified in multiple places, the "nearest" set of styles take precedence.
+ The command-line arguments are the highest priority, followed by the BAT_STYLE environment
+ variable, and then the configuration file. If any set of styles consists entirely of
+ components prefixed with "+" or "-", it will modify the previous set of styles instead of
+ replacing them.
+
By default, the following components are enabled:
changes, grid, header-filename, numbers, snip
diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs
index 8e79174b..33dde980 100644
--- a/src/bin/bat/clap_app.rs
+++ b/src/bin/bat/clap_app.rs
@@ -442,6 +442,12 @@ pub fn build_app(interactive_output: bool) -> Command {
pre-defined style ('full'). To set a default style, add the \
'--style=\"..\"' option to the configuration file or export the \
BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\").\n\n\
+ When styles are specified in multiple places, the \"nearest\" set \
+ of styles take precedence. The command-line arguments are the highest \
+ priority, followed by the BAT_STYLE environment variable, and then \
+ the configuration file. If any set of styles consists entirely of \
+ components prefixed with \"+\" or \"-\", it will modify the \
+ previous set of styles instead of replacing them.\n\n\
By default, the following components are enabled:\n \
changes, grid, header-filename, numbers, snip\n\n\
Possible values:\n\n \