From b5d156c282a01f2f1cb10aee98655a4a2c2c71e5 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 25 Dec 2021 00:14:31 -0700 Subject: [PATCH] mux: use pgrp leader basename as default pane title If the pane title is the default `wezterm`, then return the process basename instead. This makes the tab titles more useful by default, although on Windows, conpty will set the title to the initial executable path and defeat this. --- mux/src/localpane.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mux/src/localpane.rs b/mux/src/localpane.rs index 53f12e232..546e5547e 100644 --- a/mux/src/localpane.rs +++ b/mux/src/localpane.rs @@ -270,7 +270,19 @@ impl Pane for LocalPane { } fn get_title(&self) -> String { - self.terminal.borrow_mut().get_title().to_string() + let title = self.terminal.borrow_mut().get_title().to_string(); + // If the title is the default pane title, then try to spice + // things up a bit by returning the process basename instead + if title == "wezterm" { + if let Some(proc_name) = self.get_foreground_process_name() { + let proc_name = std::path::Path::new(&proc_name); + if let Some(name) = proc_name.file_name() { + return name.to_string_lossy().to_string(); + } + } + } + + title } fn palette(&self) -> ColorPalette {