1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-14 17:22:25 +01:00

Merge pull request #3376 from eric-menne/fix/ctrl-c_fails_in_powershell

Fix ctrl-c fails in powershell
This commit is contained in:
Keith Hall
2025-08-22 17:59:35 +03:00
committed by GitHub
2 changed files with 8 additions and 2 deletions

View File

@@ -646,7 +646,7 @@ If you want to pass command-line arguments to the pager, you can also set them v
`PAGER`/`BAT_PAGER` variables: `PAGER`/`BAT_PAGER` variables:
```bash ```bash
export BAT_PAGER="less -RF" export BAT_PAGER="less -RFK"
``` ```
Instead of using environment variables, you can also use `bat`'s [configuration file](#configuration-file) to configure the pager (`--pager` option). Instead of using environment variables, you can also use `bat`'s [configuration file](#configuration-file) to configure the pager (`--pager` option).
@@ -656,7 +656,7 @@ Instead of using environment variables, you can also use `bat`'s [configuration
When using `less` as a pager, `bat` will automatically pass extra options along to `less` When using `less` as a pager, `bat` will automatically pass extra options along to `less`
to improve the experience. Specifically, `-R`/`--RAW-CONTROL-CHARS`, `-F`/`--quit-if-one-screen`, to improve the experience. Specifically, `-R`/`--RAW-CONTROL-CHARS`, `-F`/`--quit-if-one-screen`,
and under certain conditions, `-X`/`--no-init` and/or `-S`/`--chop-long-lines`. `-K`/`--quit-on-intr` and under certain conditions, `-X`/`--no-init` and/or `-S`/`--chop-long-lines`.
>[!IMPORTANT] >[!IMPORTANT]
> These options will not be added if: > These options will not be added if:
@@ -674,6 +674,9 @@ The `-F` option instructs `less` to exit immediately if the output size is small
the vertical size of the terminal. This is convenient for small files because you do not the vertical size of the terminal. This is convenient for small files because you do not
have to press `q` to quit the pager. have to press `q` to quit the pager.
The `-K` option instructs `less` to exit immediately when an interrupt signal is received.
This is useful to ensure that `less` quits together with `bat` on SIGINT.
The `-X` option is needed to fix a bug with the `--quit-if-one-screen` feature in versions The `-X` option is needed to fix a bug with the `--quit-if-one-screen` feature in versions
of `less` older than version 530. Unfortunately, it also breaks mouse-wheel support in `less`. of `less` older than version 530. Unfortunately, it also breaks mouse-wheel support in `less`.
If you want to enable mouse-wheel scrolling on older versions of `less` and do not mind losing If you want to enable mouse-wheel scrolling on older versions of `less` and do not mind losing

View File

@@ -93,6 +93,9 @@ impl OutputType {
p.arg("-S"); // Short version of --chop-long-lines for compatibility p.arg("-S"); // Short version of --chop-long-lines for compatibility
} }
// Ensures that 'less' quits together with 'bat'
p.arg("-K"); // Short version of '--quit-on-intr'
// Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
// versions of 'less'. Unfortunately, it also breaks mouse-wheel support. // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
// //