Use LESS environment variables for less options
Previously, we would either use the pager set in the PAGER environment variable or "less -cr" for the rich and plain viewer. This caused problems if, for example, the PAGER environment variable was set to "less", see ticket #22: https://todo.sr.ht/~ireas/rusty-man/22 To fix this issue, we now use the LESS environment variable to set the less options. This makes sure that setting PAGER does not override the options.
This commit is contained in:
parent
56cb98e867
commit
e425da5a24
@ -5,7 +5,11 @@ SPDX-License-Identifier: MIT
|
||||
|
||||
# Changelog for rusty-man
|
||||
|
||||
# v0.4.0 (2020-10-09)
|
||||
## Unreleased
|
||||
|
||||
- Use the `LESS` environment variable to set the options for the pager.
|
||||
|
||||
## v0.4.0 (2020-10-09)
|
||||
|
||||
This minor release introduces a new interactive viewer, tui. It also adds
|
||||
syntax highlighting for code in the documentation and support for Rust 1.47.0.
|
||||
|
@ -4,6 +4,7 @@
|
||||
mod plain;
|
||||
mod rich;
|
||||
|
||||
use std::env;
|
||||
use std::io;
|
||||
|
||||
use crate::args;
|
||||
@ -63,7 +64,10 @@ impl viewer::Viewer for TextViewer {
|
||||
}
|
||||
|
||||
pub fn spawn_pager() {
|
||||
pager::Pager::with_default_pager("less -cr").setup()
|
||||
if env::var_os("LESS").is_none() {
|
||||
env::set_var("LESS", "cR");
|
||||
}
|
||||
pager::Pager::with_default_pager("less").setup()
|
||||
}
|
||||
|
||||
fn ignore_pipe_error(error: io::Error) -> io::Result<()> {
|
||||
|
Loading…
Reference in New Issue
Block a user