繁体   English   中英

如何将命令发送到给定的iTerm 2选项卡?

[英]How to send a command to a given iTerm 2 tab?

在iTerm 2 中将命令发送到另一个窗口中的给定选项卡的好方法是什么? 我认为AppleScript可能是一个好方法,但是它应该在另一个iTerm窗口中运行。

我确实找到了一种向所有选项卡广播的方法,但这是另一种功能。 还找到了一种打开新选项卡并发送命令的方法,但这也是另一种功能。

Item2具有零个或多个窗口,每个窗口具有一个或多个选项卡,并且每个选项卡具有一个或多个会话(即拆分选项卡)。

因此,您的问题是:

发送命令所需要的会话是否具有与之唯一的特性,可以对它执行相等操作以确定它是否是您要发送给的会话?

例:

  • git pull发送到名为“ Github”的会话
  • 请求所有未处理任何内容的会话回显其唯一ID

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM