mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-30 14:43:57 +00:00 
			
		
		
		
	successfully setting the terminal title to bat's input's names
This commit is contained in:
		| @@ -227,9 +227,19 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result< | ||||
|     Ok(()) | ||||
| } | ||||
|  | ||||
| fn set_terminal_title_to_inputs_names(inputs: &Vec<Input>) { | ||||
|     let mut input_names = "bat: ".to_string(); | ||||
|     for input in inputs.iter() { | ||||
|         input_names = input_names + &input.description.name.to_string() + ", " | ||||
|     } | ||||
|     print!("\x1b]2;{}\x07", input_names); | ||||
|     io::stdout().flush().unwrap(); | ||||
| } | ||||
|  | ||||
| fn run_controller(inputs: Vec<Input>, config: &Config, cache_dir: &Path) -> Result<bool> { | ||||
|     let assets = assets_from_cache_or_binary(config.use_custom_assets, cache_dir)?; | ||||
|     let controller = Controller::new(config, &assets); | ||||
|     set_terminal_title_to_inputs_names(&inputs); | ||||
|     controller.run(inputs, None) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -88,6 +88,7 @@ impl<'b> Controller<'b> { | ||||
|             clircle::Identifier::stdout() | ||||
|         }; | ||||
|  | ||||
|  | ||||
|         let mut writer = match output_buffer { | ||||
|             Some(buf) => OutputHandle::FmtWrite(buf), | ||||
|             None => OutputHandle::IoWrite(output_type.handle()?), | ||||
|   | ||||
| @@ -13,7 +13,7 @@ use crate::error::*; | ||||
| /// This tells bat how to refer to the input. | ||||
| #[derive(Clone)] | ||||
| pub struct InputDescription { | ||||
|     pub(crate) name: String, | ||||
|     pub name: String, | ||||
|  | ||||
|     /// The input title. | ||||
|     /// This replaces the name if provided. | ||||
| @@ -94,7 +94,7 @@ pub(crate) struct InputMetadata { | ||||
| pub struct Input<'a> { | ||||
|     pub(crate) kind: InputKind<'a>, | ||||
|     pub(crate) metadata: InputMetadata, | ||||
|     pub(crate) description: InputDescription, | ||||
|     pub description: InputDescription, | ||||
| } | ||||
|  | ||||
| pub(crate) enum OpenedInputKind { | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| use shell_words::ParseError; | ||||
| use std::{env, io}; | ||||
| use std::io::Write; | ||||
| use std::{env}; | ||||
|  | ||||
| /// If we use a pager, this enum tells us from where we were told to use it. | ||||
| #[derive(Debug, PartialEq)] | ||||
| @@ -37,11 +36,6 @@ pub(crate) enum PagerKind { | ||||
|     Unknown, | ||||
| } | ||||
|  | ||||
| fn set_terminal_title(title: &str) { | ||||
|     print!("\x1b]2;{}\x07", title); | ||||
|     io::stdout().flush().unwrap(); | ||||
| } | ||||
|  | ||||
| impl PagerKind { | ||||
|     fn from_bin(bin: &str) -> PagerKind { | ||||
|         use std::path::Path; | ||||
| @@ -108,7 +102,6 @@ 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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user