【问题标题】:Set Terminal tab name w/ AppleScript使用 AppleScript 设置终端选项卡名称
【发布时间】:2012-01-16 20:39:36
【问题描述】:

我有以下脚本,它打开终端,连接到远程主机并在那里启动脚本:

tell application "Terminal"
    activate
    do script "ssh me@myserver" 
    delay 10
    do script "sh ./startserver" in front window    
end tell

如何设置此终端选项卡的名称?

【问题讨论】:

    标签: macos terminal applescript


    【解决方案1】:
    tell app "Terminal" to set custom title of tab 1 of front window to "my tab name"
    

    【讨论】:

    • IMO,这是 AppleScript 的更好选择。
    【解决方案2】:
    tell application "Terminal"
        activate
        do script "ssh me@myserver" 
        delay 10
        do script "sh ./startserver" in front window 
        set input to "\"\\033]0;<your title here>\\007\""
        do script "echo -n -e " & input   
    end tell
    

    &lt;your title here&gt; 替换为您希望标题的任何文本。

    【讨论】:

    • 如果我在最后一个 do script 中添加 in front window 就可以了,谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-05-09
    • 1970-01-01
    • 1970-01-01
    • 2015-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多