-
Notifications
You must be signed in to change notification settings - Fork 0
claude/fix-tmux-process-name-qIIsu #211
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 |
|---|---|---|
|
|
@@ -7,54 +7,57 @@ import ( | |
| "strings" | ||
| ) | ||
|
|
||
| // Known terminal emulator process names | ||
| var knownTerminals = map[string]bool{ | ||
| // Known terminal emulator process names (lowercase for case-insensitive matching) | ||
| var knownTerminals = []string{ | ||
| // macOS | ||
| "Terminal": true, | ||
| "iTerm2": true, | ||
| "Alacritty": true, | ||
| "alacritty": true, | ||
| "kitty": true, | ||
| "WezTerm": true, | ||
| "wezterm": true, | ||
| "wezterm-gui": true, | ||
| "Hyper": true, | ||
| "Tabby": true, | ||
| "Warp": true, | ||
| "Ghostty": true, | ||
| "ghostty": true, | ||
| "terminal", | ||
| "iterm2", | ||
| "alacritty", | ||
| "kitty", | ||
| "wezterm", | ||
| "hyper", | ||
| "tabby", | ||
| "warp", | ||
| "ghostty", | ||
| // Linux | ||
| "gnome-terminal": true, | ||
| "gnome-terminal-": true, // gnome-terminal-server | ||
| "konsole": true, | ||
| "xfce4-terminal": true, | ||
| "xterm": true, | ||
| "urxvt": true, | ||
| "rxvt": true, | ||
| "terminator": true, | ||
| "tilix": true, | ||
| "st": true, | ||
| "foot": true, | ||
| "footclient": true, | ||
| "gnome-terminal", | ||
| "konsole", | ||
| "xfce4-terminal", | ||
| "xterm", | ||
| "urxvt", | ||
| "rxvt", | ||
| "terminator", | ||
| "tilix", | ||
| "foot", | ||
| // IDE terminals | ||
| "code": true, | ||
| "Code": true, | ||
| "cursor": true, | ||
| "Cursor": true, | ||
| "code", | ||
| "cursor", | ||
| } | ||
|
|
||
| // Known terminal multiplexer process names | ||
| var knownMultiplexers = map[string]bool{ | ||
| "tmux": true, | ||
| "screen": true, | ||
| "zellij": true, | ||
| // Known terminal multiplexer process names (lowercase for case-insensitive matching) | ||
| var knownMultiplexers = []string{ | ||
| "tmux", | ||
| "screen", | ||
| "zellij", | ||
| } | ||
|
|
||
| // Known remote/container process names | ||
| var knownRemote = map[string]bool{ | ||
| "sshd": true, | ||
| "docker": true, | ||
| "containerd": true, | ||
| // Known remote/container process names (lowercase for case-insensitive matching) | ||
| var knownRemote = []string{ | ||
| "sshd", | ||
| "docker", | ||
| "containerd", | ||
| } | ||
|
|
||
| // matchKnownName checks if processName contains any of the known names (case-insensitive) | ||
| // Returns the matched known name if found, empty string otherwise | ||
| func matchKnownName(processName string, knownNames []string) string { | ||
| lowerName := strings.ToLower(processName) | ||
| for _, known := range knownNames { | ||
| if strings.Contains(lowerName, known) { | ||
| return known | ||
| } | ||
| } | ||
| return "" | ||
| } | ||
|
|
||
| // ResolveTerminal walks up the process tree starting from ppid | ||
|
|
@@ -81,18 +84,24 @@ func ResolveTerminal(ppid int) (terminal string, multiplexer string) { | |
| } | ||
|
|
||
| // Check for multiplexers first (they're closer to the shell) | ||
| if multiplexer == "" && knownMultiplexers[processName] { | ||
| multiplexer = processName | ||
| if multiplexer == "" { | ||
| if matched := matchKnownName(processName, knownMultiplexers); matched != "" { | ||
| multiplexer = matched | ||
| } | ||
| } | ||
|
Comment on lines
+87
to
91
Contributor
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. This conditional assignment can be made more concise. Since if multiplexer == "" {
multiplexer = matchKnownName(processName, knownMultiplexers)
} |
||
|
|
||
| // Check for terminals | ||
| if terminal == "" && knownTerminals[processName] { | ||
| terminal = processName | ||
| if terminal == "" { | ||
| if matched := matchKnownName(processName, knownTerminals); matched != "" { | ||
| terminal = matched | ||
| } | ||
| } | ||
|
Comment on lines
+94
to
98
Contributor
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. |
||
|
|
||
| // Check for remote connections | ||
| if terminal == "" && knownRemote[processName] { | ||
| terminal = processName | ||
| if terminal == "" { | ||
| if matched := matchKnownName(processName, knownRemote); matched != "" { | ||
| terminal = matched | ||
| } | ||
| } | ||
|
Comment on lines
+101
to
105
Contributor
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. |
||
|
|
||
| // If we found a terminal, we can stop | ||
|
|
||
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
stterminal emulator, which was present in the previous version, appears to have been removed from theknownTerminalslist. This seems like an unintentional omission that would preventstfrom being detected. I recommend adding it back.