iTerm2 Python API 拆分标签
iTerm2 Python API Split Tab
使用 iTerm Python API added in the 3.3.0 版本,是否可以水平 拆分 选项卡?
等同于;
Right Click -> Split Pane Horizontally
import iterm2
async def main(connection):
# Get app
app = await iterm2.async_get_app(connection)
# current window
window = app.current_terminal_window
if window is not None:
# Create main & sub tab
main = await window.async_create_tab()
await main.async_set_title('~ MAIN ~')
sub = await window.async_create_tab()
await sub.async_set_title('~ SUB ~')
# Split sub
...
发送默认击键 (command + d) .
iTerm Python API has an async_split_pane
可以拆分窗格的方法:
tab = await window.async_create_tab()
session = tab.current_session
splited = await session.async_split_pane(vertical=False)
Session负责拆分一个tab。
如果要拆分新创建的窗格,请执行以下操作:
await splited.async_activate()
await session2.async_split_pane(vertical=True)
你的例子:
#!/usr/bin/env python3.7
import iterm2
async def main(connection):
# Get app
print("Test::main")
app = await iterm2.async_get_app(connection)
# Ensure window
window = app.current_terminal_window
if app.current_terminal_window is None:
exit()
# Create main tab
main = await window.async_create_tab()
await main.async_activate()
await main.async_set_title('~ Title ~')
sess = main.current_session
# Split main
sub = await sess.async_split_pane(vertical=True)
await sub.async_send_text('whoami\n')
iterm2.run_until_complete(main)
使用 iTerm Python API added in the 3.3.0 版本,是否可以水平 拆分 选项卡? 等同于;
Right Click -> Split Pane Horizontally
import iterm2
async def main(connection):
# Get app
app = await iterm2.async_get_app(connection)
# current window
window = app.current_terminal_window
if window is not None:
# Create main & sub tab
main = await window.async_create_tab()
await main.async_set_title('~ MAIN ~')
sub = await window.async_create_tab()
await sub.async_set_title('~ SUB ~')
# Split sub
...
发送默认击键 (command + d)
iTerm Python API has an async_split_pane
可以拆分窗格的方法:
tab = await window.async_create_tab()
session = tab.current_session
splited = await session.async_split_pane(vertical=False)
Session负责拆分一个tab。 如果要拆分新创建的窗格,请执行以下操作:
await splited.async_activate()
await session2.async_split_pane(vertical=True)
你的例子:
#!/usr/bin/env python3.7
import iterm2
async def main(connection):
# Get app
print("Test::main")
app = await iterm2.async_get_app(connection)
# Ensure window
window = app.current_terminal_window
if app.current_terminal_window is None:
exit()
# Create main tab
main = await window.async_create_tab()
await main.async_activate()
await main.async_set_title('~ Title ~')
sess = main.current_session
# Split main
sub = await sess.async_split_pane(vertical=True)
await sub.async_send_text('whoami\n')
iterm2.run_until_complete(main)