打开 2 个用 zsh & 分割的屏幕iterm2 通过脚本 [英] Open 2 screens split with zsh & iterm2 via script

查看:27
本文介绍了打开 2 个用 zsh & 分割的屏幕iterm2 通过脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to have a script which would be able to open 1 iterm tab which contains 2 split screens inside via script.

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

Is it possible or should I install an additional lib for that?

推荐答案

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

Yes! This is possible without any external libraries.

使用 osascript 将命令发送"到 Iterm 这个简单的 脚本应该打开一个新标签,拆分它并调用一些命令;

Using osascript to 'send' commands to Iterm this simple bash script should open a new tab, split it and call some commands;

#!/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

脚本录屏 (.gif)

这篇关于打开 2 个用 zsh &amp; 分割的屏幕iterm2 通过脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆