【问题标题】:Open 2 screens split with zsh & iterm2 via script通过脚本打开 2 个使用 zsh 和 iterm2 分割的屏幕
【发布时间】:2021-01-05 03:39:05
【问题描述】:

我想要一个脚本,它能够通过脚本打开 1 个 iterm 选项卡,其中包含 2 个分屏。

是否有可能或者我应该为此安装一个额外的库?

【问题讨论】:

    标签: zsh iterm2 oh-my-zsh iterm


    【解决方案1】:

    是的!这在没有任何外部库的情况下是可能的。

    使用osascript 向Iterm“发送”命令这个简单的 脚本应该打开一个新选项卡,将其拆分并调用一些命令;

    #!/bin/bash
    
    osascript<<EOF
        tell application "iTerm"
            activate
            select first window
    
            # Create new tab
            tell current window
                create tab with default profile
            end tell
    
            # Split pane
            tell current session of current window
                split vertically with default profile
            end tell
    
            # Run command in Pane-1
            tell first session of current tab of current window
                write text "cd /tmp"
                write text "pwd"
            end tell
    
            # Run command in Pane-2
            tell second session of current tab of current window
                write text "echo Second tab!;"
            end tell
        end tell
    EOF
    

    Screen recording of script (.gif)

    【讨论】:

    • 谢谢你,你帮了我很大的忙。谢谢...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 2018-04-27
    • 2020-02-20
    • 2023-03-24
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多