mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-26 08:18:50 +01:00
able to set terminal title to hardcoded value
This commit is contained in:
parent
28990bc451
commit
2e103ee6b3
14
src/pager.rs
14
src/pager.rs
@ -1,5 +1,6 @@
|
||||
use shell_words::ParseError;
|
||||
use std::env;
|
||||
use std::{env, io};
|
||||
use std::io::Write;
|
||||
|
||||
/// If we use a pager, this enum tells us from where we were told to use it.
|
||||
#[derive(Debug, PartialEq)]
|
||||
@ -36,6 +37,16 @@ pub(crate) enum PagerKind {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
fn set_terminal_title(title: &str) {
|
||||
print!("\x1b]2;{}\x07", title);
|
||||
io::stdout().flush().unwrap();
|
||||
}
|
||||
|
||||
fn restore_terminal_title() {
|
||||
print!("\x1b]2;\x07");
|
||||
io::stdout().flush().unwrap();
|
||||
}
|
||||
|
||||
impl PagerKind {
|
||||
fn from_bin(bin: &str) -> PagerKind {
|
||||
use std::path::Path;
|
||||
@ -102,6 +113,7 @@ pub(crate) fn get_pager(config_pager: Option<&str>) -> Result<Option<Pager>, Par
|
||||
};
|
||||
|
||||
let parts = shell_words::split(cmd)?;
|
||||
set_terminal_title("test");
|
||||
match parts.split_first() {
|
||||
Some((bin, args)) => {
|
||||
let kind = PagerKind::from_bin(bin);
|
||||
|
Loading…
Reference in New Issue
Block a user