是的!无需任何外部库即可实现这一点。
使用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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1843 次 |
| 最近记录: |