通过脚本打开 2 个用 zsh 和 iterm2 分割的屏幕
Open 2 screens split with zsh & iterm2 via script
我想要一个脚本,它可以通过脚本打开 1 个项目选项卡,其中包含 2 个分屏。
是否可以或者我应该为此安装一个额外的库?
是的!这在没有任何外部库的情况下是可能的。
使用 osascript to 'send' commands to Iterm this simple 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
Screen recording of script (.gif
)
我想要一个脚本,它可以通过脚本打开 1 个项目选项卡,其中包含 2 个分屏。
是否可以或者我应该为此安装一个额外的库?
是的!这在没有任何外部库的情况下是可能的。
使用 osascript to 'send' commands to Iterm this simple 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
Screen recording of script (.gif
)