summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-10-04 13:34:19 -0400
committerDan Davison <dandavison7@gmail.com>2020-10-04 13:34:19 -0400
commit31e2661cde45c573be727f6d30e0c24a0983b12f (patch)
tree8f9d41aebfcc530820df26b6325b83521ac8e8e0
parent166d31a7d3ad410243405451cd2e0bd910f32c6e (diff)
Support DELTA_PAGER env var
-rw-r--r--src/bat/output.rs21
-rw-r--r--src/cli.rs4
-rw-r--r--src/options/theme.rs2
3 files changed, 15 insertions, 12 deletions
diff --git a/src/bat/output.rs b/src/bat/output.rs
index 3f53ca97..b8a38653 100644
--- a/src/bat/output.rs
+++ b/src/bat/output.rs
@@ -50,15 +50,18 @@ impl OutputType {
) -> Result<Self> {
let mut replace_arguments_to_less = false;
- let pager_from_env = match (env::get_env_var("BAT_PAGER"), env::get_env_var("PAGER")) {
- (Some(bat_pager), _) => Some(bat_pager),
- (_, Some(pager)) => {
- // less needs to be called with the '-R' option in order to properly interpret the
- // ANSI color sequences printed by bat. If someone has set PAGER="less -F", we
- // therefore need to overwrite the arguments and add '-R'.
- //
- // We only do this for PAGER (as it is not specific to 'bat'), not for BAT_PAGER
- // or bats '--pager' command line option.
+ let pager_from_env = match (
+ env::get_env_var("DELTA_PAGER"),
+ env::get_env_var("BAT_PAGER"),
+ env::get_env_var("PAGER"),
+ ) {
+ (Some(delta_pager), _, _) => Some(delta_pager),
+ (None, Some(bat_pager), _) => Some(bat_pager),
+ (None, None, Some(pager)) => {
+ // less needs to be called with the '-R' option in order to properly interpret ANSI
+ // color sequences. If someone has set PAGER="less -F", we therefore need to
+ // overwrite the arguments and add '-R'.
+ // We only do this for PAGER, since it is used in other contexts.
replace_arguments_to_less = true;
Some(pager)
}
diff --git a/src/cli.rs b/src/cli.rs
index 6c29f9dc..863b2af5 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -477,8 +477,8 @@ pub struct Opt {
pub inspect_raw_lines: String,
/// Whether to use a pager when displaying output. Options are: auto, always, and never. The
- /// default pager is `less`: this can be altered by setting the environment variables BAT_PAGER
- /// or PAGER (BAT_PAGER has priority).
+ /// default pager is `less`: this can be altered by setting the environment variables
+ /// DELTA_PAGER, BAT_PAGER, or PAGER (and that is their order of priority).
#[structopt(long = "paging", default_value = "auto")]
pub paging_mode: String,
diff --git a/src/options/theme.rs b/src/options/theme.rs
index 8dc235e0..909b29f8 100644
--- a/src/options/theme.rs
+++ b/src/options/theme.rs
@@ -65,7 +65,7 @@ fn is_no_syntax_highlighting_syntax_theme_name(theme_name: &str) -> bool {
///
/// Basically:
/// 1. The theme is specified by the `--theme` option. If this isn't supplied then it is specified
-/// by the `BAT_PAGER` environment variable.
+/// by the `BAT_THEME` environment variable.
/// 2. Light vs dark mode is specified by the `--light` or `--dark` options. If these aren't
/// supplied then it is inferred from the chosen theme.
///