[PATCH] Set title under tmux(1)

[PATCH] Set title under tmux(1)

From: Klemens Nanni
tmux accepts both "screen" and "tmux" as TERM values in order to
fully support programs running inside tmux.

This is especially useful for chat.tmux.conf's F1 "pick chat network"
where clipped tmux window previews lacked the first lines containing
catgirl's window name -- now tmux's listing nicely shows network and
window names filling that spot, e.g.
	(2) └─> 1: catgirl*: "tilde.chat #ascii.town (+1)"
---
 ui.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ui.c b/ui.c
index 9d67387..cf133da 100644
--- a/ui.c
+++ b/ui.c
@@ -249,7 +249,11 @@ void uiInitEarly(void) {
 	enter_blink_mode = enter_italics_mode;
 #endif
 
-	if (!to_status_line && !strncmp(termname(), "xterm", 5)) {
+	bool setTitle = false
+		|| !strncmp(termname(), "screen", 6)
+		|| !strncmp(termname(), "tmux", 5)
+		|| !strncmp(termname(), "xterm", 5);
+	if (!to_status_line && setTitle) {
 		to_status_line = "\33]2;";
 		from_status_line = "\7";
 	}
-- 
2.32.0

Re: [PATCH] Set title under tmux(1)

From: june
> On Jun 27, 2021, at 06:58, Klemens Nanni <klemens@posteo.de> wrote:
> 
> -	if (!to_status_line && !strncmp(termname(), "xterm", 5)) {
> +	bool setTitle = false
> +		|| !strncmp(termname(), "screen", 6)
> +		|| !strncmp(termname(), "tmux", 5)
> +		|| !strncmp(termname(), "xterm", 5);

tmux’s terminfo already has a to_status_line string (tput -T tmux
tsl), and I’d rather not hardcode more terminals. On the other hand
screen doesn’t have one, despite tmux’s tsl string also working in
screen. terminfo sucks.