-
Notifications
You must be signed in to change notification settings - Fork 529
TerminalShell (Linux): better support for Ghostty #1803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -576,6 +576,25 @@ static bool getTerminalVersionZed(FFstrbuf* exe, FFstrbuf* version) | |
return true; | ||
} | ||
|
||
static bool getTerminalVersionGhostty(FFstrbuf* exe, FFstrbuf* version) | ||
{ | ||
const char* env = getenv("TERM_PROGRAM_VERSION"); | ||
if (env) | ||
{ | ||
ffStrbufAppendS(version, env); | ||
// 1.1.3-arch1 | ||
ffStrbufSubstrBeforeFirstC(version, '-'); | ||
if(version->length > 0) return true; | ||
} | ||
|
||
if(!getExeVersionRaw(exe, version)) return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually dont think this is needed. As $TERMINAL_PROGRAM_VERSION exists. Note we always add another detection method after ffBinaryExtractStrings usage, as ffBinaryExtractStrings relies on the internal implementation of terminals which is not very reliable. While $TERMINAL_PROGRAM_VERSION is considerred a public API; if the variable is not there it is a terminal bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
// Ghostty 1.1.3-arch1\n\nVersion\n... | ||
ffStrbufSubstrBeforeFirstC(version, '\n'); // Ghostty 1.1.3-arch1 | ||
ffStrbufSubstrAfterFirstC(version, ' '); // 1.1.3-arch1, only Arch Linux has the suffix '-arch1' | ||
ffStrbufSubstrBeforeFirstC(version, '-'); // 1.1.3 | ||
return version->length > 0; | ||
} | ||
|
||
#ifndef _WIN32 | ||
static bool getTerminalVersionKitty(FFstrbuf* exe, FFstrbuf* version) | ||
{ | ||
|
@@ -873,6 +892,9 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe | |
if(ffStrbufStartsWithIgnCaseS(processName, "zed")) | ||
return getTerminalVersionZed(exe, version); | ||
|
||
if(ffStrbufStartsWithIgnCaseS(processName, "ghostty")) | ||
return getTerminalVersionGhostty(exe, version); | ||
|
||
#if __HAIKU__ | ||
if(ffStrbufEqualS(processName, "Terminal")) | ||
return ffGetFileVersion(exe->chars, version); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI fedora version also includes
.fc42
. Lets keep as it was.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For nightly version,
ghostty --version
includes the branch name and commit hash.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The kernel version contains archlinux specific suffix
-arch1-1
. I don't think it's problematic. Do you?