mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-23 08:13:26 +01:00
Disable paging-mode if we read from an interactive TTY
This commit is contained in:
parent
9a0e444e09
commit
8a399c8d7d
39
src/main.rs
39
src/main.rs
@ -455,6 +455,21 @@ fn run() -> Result<()> {
|
|||||||
assets.save()?;
|
assets.save()?;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
let files: Vec<Option<&str>> = app_matches
|
||||||
|
.values_of("FILE")
|
||||||
|
.map(|values| {
|
||||||
|
values
|
||||||
|
.map(|filename| {
|
||||||
|
if filename == "-" {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(filename)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| vec![None]); // read from stdin (None) if no args are given
|
||||||
|
|
||||||
let options = Options {
|
let options = Options {
|
||||||
true_color: is_truecolor_terminal(),
|
true_color: is_truecolor_terminal(),
|
||||||
style: match app_matches.value_of("style") {
|
style: match app_matches.value_of("style") {
|
||||||
@ -476,7 +491,14 @@ fn run() -> Result<()> {
|
|||||||
paging: match app_matches.value_of("paging") {
|
paging: match app_matches.value_of("paging") {
|
||||||
Some("always") => true,
|
Some("always") => true,
|
||||||
Some("never") => false,
|
Some("never") => false,
|
||||||
Some("auto") | _ => interactive_terminal,
|
Some("auto") | _ => if files.contains(&None) {
|
||||||
|
// If we are reading from stdin, only enable paging if we write to an
|
||||||
|
// interactive terminal and if we do not *read* from an interactive
|
||||||
|
// terminal.
|
||||||
|
interactive_terminal && !atty::is(Stream::Stdin)
|
||||||
|
} else {
|
||||||
|
interactive_terminal
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -490,21 +512,6 @@ fn run() -> Result<()> {
|
|||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let files: Vec<Option<&str>> = app_matches
|
|
||||||
.values_of("FILE")
|
|
||||||
.map(|values| {
|
|
||||||
values
|
|
||||||
.map(|filename| {
|
|
||||||
if filename == "-" {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(filename)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
})
|
|
||||||
.unwrap_or_else(|| vec![None]); // read from stdin (None) if no args are given
|
|
||||||
|
|
||||||
let mut output_type = get_output_type(options.paging);
|
let mut output_type = get_output_type(options.paging);
|
||||||
let handle = output_type.handle()?;
|
let handle = output_type.handle()?;
|
||||||
let mut printer = Printer::new(handle, &options);
|
let mut printer = Printer::new(handle, &options);
|
||||||
|
Loading…
Reference in New Issue
Block a user