【发布时间】:2016-11-15 19:04:11
【问题描述】:
在iTerm 2 中在另一个窗口 中向给定选项卡发送命令的好方法是什么?我认为 AppleScript 可能是一个好方法,但它应该在另一个 iTerm 窗口中运行。
我确实找到了一种向所有标签广播的方法,但这是一个不同的功能。还找到了一种打开新标签并发送命令的方法,但这也是一个不同的功能。
【问题讨论】:
标签: macos applescript iterm2
在iTerm 2 中在另一个窗口 中向给定选项卡发送命令的好方法是什么?我认为 AppleScript 可能是一个好方法,但它应该在另一个 iTerm 窗口中运行。
我确实找到了一种向所有标签广播的方法,但这是一个不同的功能。还找到了一种打开新标签并发送命令的方法,但这也是一个不同的功能。
【问题讨论】:
标签: macos applescript iterm2
Item2 有零个或多个窗口,每个窗口有一个或多个选项卡,每个选项卡有一个或多个会话(即拆分选项卡)。
您需要发送命令的会话是否有一些独特之处,您可以对其执行相等以确定它是否是您需要发送到的会话?
git pull
.
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
【讨论】: