mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-07 13:41:14 +00: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 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.
|
/// If we use a pager, this enum tells us from where we were told to use it.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
@ -36,6 +37,16 @@ pub(crate) enum PagerKind {
|
|||||||
Unknown,
|
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 {
|
impl PagerKind {
|
||||||
fn from_bin(bin: &str) -> PagerKind {
|
fn from_bin(bin: &str) -> PagerKind {
|
||||||
use std::path::Path;
|
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)?;
|
let parts = shell_words::split(cmd)?;
|
||||||
|
set_terminal_title("test");
|
||||||
match parts.split_first() {
|
match parts.split_first() {
|
||||||
Some((bin, args)) => {
|
Some((bin, args)) => {
|
||||||
let kind = PagerKind::from_bin(bin);
|
let kind = PagerKind::from_bin(bin);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user