Skip to content

Commit 611de77

Browse files
committed
Terminal (macOS): improve performance of kitty version
1 parent 0fde835 commit 611de77

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/detection/terminalshell/terminalshell.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,38 @@ static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version)
598598
}
599599
}
600600
}
601+
#elif __APPLE__
602+
if (ffStrbufEndsWithS(exe, "/kitty.app/Contents/MacOS/kitty"))
603+
{
604+
ffStrbufSet(version, exe);
605+
ffStrbufSubstrBeforeLastC(version, '/');
606+
ffStrbufSubstrBeforeLastC(version, '/');
607+
ffStrbufAppendS(version, "/Info.plist");
608+
char buf[4096];
609+
ssize_t size = ffReadFileData(version->chars, ARRAY_SIZE(buf) - 1, buf);
610+
if (size > 0)
611+
{
612+
buf[size] = '\0';
613+
614+
const char* p = strstr(buf, "<key>CFBundleShortVersionString</key>");
615+
if (p)
616+
{
617+
p += strlen("<key>CFBundleShortVersionString</key>");
618+
p = strchr(p, '>');
619+
if (p)
620+
{
621+
p++;
622+
const char* end = strchr(p, '<');
623+
if (end)
624+
{
625+
ffStrbufSetNS(version, (uint32_t) (end - p), p);
626+
return true;
627+
}
628+
}
629+
}
630+
}
631+
ffStrbufClear(version);
632+
}
601633
#endif
602634

603635
char versionHex[64];

0 commit comments

Comments
 (0)