Skip to content

Commit 1d1eeed

Browse files
ZhaoChaoqunclaude
andauthored
refactor: simplify detect_terminal by removing unused host_terminal variable (#11)
tmux.sh already detects the host terminal on its own, so the main detector doesn't need to track it. Return immediately on first match. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c6afb27 commit 1d1eeed

1 file changed

Lines changed: 6 additions & 21 deletions

File tree

claude-notify/notify.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,34 +87,19 @@ def detect_terminal(pid=None):
8787

8888
tree = get_process_tree()
8989

90-
found_tmux = False
91-
host_terminal = "unknown"
92-
9390
for _, comm in walk_ancestors(pid, tree):
9491
name = os.path.basename(comm).lower()
9592

96-
# cmux check — highest priority
9793
if "cmux" in name:
9894
return "cmux"
99-
100-
# tmux check — remember we found it, but keep looking for host
10195
if name.startswith("tmux"):
102-
found_tmux = True
103-
continue
104-
105-
# Terminal emulator checks
96+
return "tmux"
10697
if name in ("iterm2", "iterm", "itermserver-main"):
107-
host_terminal = "iterm2"
108-
if found_tmux:
109-
break
110-
elif name == "terminal" or name == "terminal.app":
111-
host_terminal = "terminal_app"
112-
if found_tmux:
113-
break
114-
115-
if found_tmux:
116-
return "tmux"
117-
return host_terminal
98+
return "iterm2"
99+
if name in ("terminal", "terminal.app"):
100+
return "terminal_app"
101+
102+
return "unknown"
118103

119104

120105
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)