Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning up output from the pager #77

Closed
BrainMaestro opened this issue May 7, 2018 · 7 comments
Closed

Cleaning up output from the pager #77

BrainMaestro opened this issue May 7, 2018 · 7 comments

Comments

@BrainMaestro
Copy link
Contributor

BrainMaestro commented May 7, 2018

For the pager (less), we use the option --no-init which is used by git as well. It causes the output to remain on the terminal instead of being cleaned up like typical less would do. I actually do not like this behavior and would prefer to remove it. Is there a reason it should be kept? Thoughts?

@BrainMaestro
Copy link
Contributor Author

To remove that flag, we would also need to remove --quit-if-one-screen for short files to work correctly which might not be worth it. Reopen this if you feel differently

@sharkdp
Copy link
Owner

sharkdp commented May 7, 2018

To remove that flag, we would also need to remove --quit-if-one-screen for short files to work correctly

Really? It seems to work for me..

@BrainMaestro
Copy link
Contributor Author

Short files like Cargo.toml work if you remove --no-init?

@sharkdp
Copy link
Owner

sharkdp commented May 7, 2018

Yes, it seems to work, but I'm not sure if I'm missing something:

▶ git diff
diff --git a/src/main.rs b/src/main.rs
index 6f5980a..6a41a13 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -77,7 +77,7 @@ enum OutputType<'a> {
 impl<'a> OutputType<'a> {
     fn pager() -> Result<Self> {
         Ok(OutputType::Pager(Command::new("less")
-            .args(&["--quit-if-one-screen", "--RAW-CONTROL-CHARS", "--no-init"])
+            .args(&["--quit-if-one-screen", "--RAW-CONTROL-CHARS"])
             .stdin(Stdio::piped())
             .spawn()
             .chain_err(|| "Could not spawn pager")?))

▶ cargo run -- Cargo.toml
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/bat Cargo.toml`
───────┬───────────────────────────────────────────────────────────────────────
       │ File Cargo.toml
───────┼───────────────────────────────────────────────────────────────────────
   1   │ [package]
   2   │ authors = ["David Peter <[email protected]>"]
   3   │ categories = ["command-line-utilities"]
   4   │ description="A cat(1) clone with wings."
   5   │ homepage = "https://github.com/sharkdp/bat"
   6   │ license = "MIT/Apache-2.0"
   7   │ name = "bat"
   8   │ readme = "README.md"
   9   │ repository = "https://github.com/sharkdp/bat"
  10   │ version = "0.2.3"
  11   │ 
  12   │ [dependencies]
  13   │ atty = "0.2.2"
  14   │ ansi_term = "0.9"
  15   │ console = "0.6"
  16   │ error-chain = "0.11"
  17   │ directories = "0.9"
  18   │ lazy_static = "1.0"
  19   │ 
  20   │ [dependencies.git2]
  21   │ version = "0.6"
  22   │ default-features = false
  23   │ features = []
  24   │ 
  25   │ [dependencies.syntect]
  26   │ version = "2"
  27   │ default-features = false
  28   │ features = ["parsing", "yaml-load", "dump-load", "dump-create"]
  29   │ 
  30   │ [dependencies.clap]
  31   │ version = "2"
  32   │ default-features = false
  33   │ features = ["suggestions", "color", "wrap_help"]
───────┴───────────────────────────────────────────────────────────────────────

(the output is directly shown, no paging mode)

@BrainMaestro
Copy link
Contributor Author

Hmm, might be a difference with GNU less in linux and the old BSD one in macOS. Guess we should just ignore this then

@dufferzafar
Copy link

@BrainMaestro I too want to have the pager clear its output upon quitting.

Is there a way I can go about configuring this for myself?

@BrainMaestro
Copy link
Contributor Author

@dufferzafar not that I know of, but if #158 is implemented, then it should be easy to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants