From e046787aeca230693b4df792978258e15af4efcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 26 Feb 2024 23:33:30 +0800 Subject: [PATCH] Terminal: better tmux version detection --- src/detection/terminalshell/terminalshell.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index be83accd5..bd21025b2 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -423,6 +423,20 @@ static bool getTerminalVersionScreen(FFstrbuf* exe, FFstrbuf* version) return version->length > 0; } +static bool getTerminalVersionTmux(FFstrbuf* exe, FFstrbuf* version) +{ + if (ffProcessAppendStdOut(version, (char* const[]) { + exe->chars, + "-V", + NULL + }) != NULL) + return false; + + // tmux 3.4 + ffStrbufSubstrAfterFirstC(version, ' '); + return version->length > 0; +} + #ifdef _WIN32 static bool getTerminalVersionWindowsTerminal(FFstrbuf* exe, FFstrbuf* version) @@ -572,6 +586,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe } } + if(ffStrbufStartsWithIgnCaseS(processName, "tmux")) + return getTerminalVersionTmux(exe, version); + #ifdef _WIN32 return getFileVersion(exe->chars, version);