diff options
| author | Peter Holloway <holloway.p.r@gmail.com> | 2024-01-19 11:16:25 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-19 11:16:25 +0000 |
| commit | cda135d241c7e66d4f371d5c13a4501b1002e4e8 (patch) | |
| tree | 42a71396df38dda61c3447f61f675edbdaaef8e6 | |
| parent | Escape control characters using caret notation (#1585) (diff) | |
| download | atuin-cda135d241c7e66d4f371d5c13a4501b1002e4e8.zip | |
fix: Print literal control characters to non terminals (#1586)
* Print literal control characters to non terminals
Previous 'fix' to prevent control sequences being interpreted when they
shouldn't have been also prevented them being used when they should have
been. This checks if the output is to a terminal (where control
sequences shouldn't be interpreted) before escaping control characters.
* Update atuin/src/command/client/search.rs
Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
---------
Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
| -rw-r--r-- | atuin/src/command/client/search.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/atuin/src/command/client/search.rs b/atuin/src/command/client/search.rs index 456dc391..a929abd9 100644 --- a/atuin/src/command/client/search.rs +++ b/atuin/src/command/client/search.rs @@ -1,3 +1,5 @@ +use std::io::{stderr, IsTerminal as _}; + use atuin_common::utils::{self, Escapable as _}; use clap::Parser; use eyre::Result; @@ -167,7 +169,11 @@ impl Cmd { if self.interactive { let item = interactive::history(&self.query, settings, db, &history_store).await?; - eprintln!("{}", item.escape_control()); + if stderr().is_terminal() { + eprintln!("{}", item.escape_control()); + } else { + eprintln!("{item}"); + } } else { let list_mode = ListMode::from_flags(self.human, self.cmd_only); |
