如何解决通过脚本用zsh和iterm2打开2个屏幕
我希望有一个脚本,该脚本能够通过脚本打开1个iterm选项卡,其中包含2个拆分屏幕。
是否可以,或者应该为此安装一个额外的库?
解决方法
是的!无需任何外部库,这是可能的。
使用osascript将命令“发送”到Iterm这个简单的bash脚本应打开一个新标签页,将其拆分并调用一些命令;
#!/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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。