将命令发送到iTerm 2中给定标签 在另一个窗口中 的好方法是什么?我认为AppleScript可能是一个好方法,但它应该在另一个iTerm窗口中运行。
我确实找到了一种向所有标签广播的方法,但这是一个不同的功能。还找到了一种打开新选项卡并发送命令的方法,但这也是一个不同的功能。
答案 0 :(得分:2)
Item2有零个或多个窗口,每个窗口都有一个或多个选项卡,每个选项卡都有一个或多个会话(即拆分标签)。
您发送命令所需的会话是否具有与之相关的独特之处,您可以执行相等操作以确定它是否是您需要发送到的那个?
git pull
发送到名为" Github"
tell application "iTerm"
repeat with aWindow in windows
tell aWindow
repeat with aTab in tabs
tell aTab
repeat with aSession in sessions
tell aSession
if (name = "GitHub") then
write text "git pull"
end if
if (is at shell prompt) then
set uniqueID to "echo StackoverFlow: " & id
write text uniqueID
end if
end tell
end repeat
end tell
end repeat
end tell
end repeat
end tell
session
字典properties
id (text, r/o) : The unique identifier of the session.
is processing (boolean) : The session has received output recently.
is at shell prompt (boolean) : The terminal is at the shell prompt. Requires shell integration.
columns (integer)
rows (integer)
tty (text, r/o)
contents (text) : The currently visible contents of the session.
text (text, r/o) : The currently visible contents of the session.
background color (RGB color)
bold color (RGB color)
cursor color (RGB color)
cursor text color (RGB color)
foreground color (RGB color)
selected text color (RGB color)
selection color (RGB color)
ANSI black color (RGB color)
ANSI red color (RGB color)
ANSI green color (RGB color)
ANSI yellow color (RGB color)
ANSI blue color (RGB color)
ANSI magenta color (RGB color)
ANSI cyan color (RGB color)
ANSI white color (RGB color)
ANSI bright black color (RGB color)
ANSI bright red color (RGB color)
ANSI bright green color (RGB color)
ANSI bright yellow color (RGB color)
ANSI bright blue color (RGB color)
ANSI bright magenta color (RGB color)
ANSI bright cyan color (RGB color)
ANSI bright white color (RGB color)
background image (text)
name (text)
transparency (real)
unique ID (text, r/o)
profile name (text, r/o) : The session's profile name
answerback string (text) : ENQ Answerback string