Skip to content

Commit

Permalink
Server.acmd: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Dec 25, 2024
1 parent df7df77 commit a19a9f0
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions src/libtmux/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,32 +258,47 @@ async def acmd(
Examples
--------
>>> server.acmd('display-message', 'hi')
<libtmux.common.AsyncTmuxCmd object at ...>
>>> import asyncio
>>> async def test_acmd():
... result = await server.acmd('display-message', 'hi')
... print(result.stdout)
>>> asyncio.run(test_acmd())
[]
New session:
>>> server.acmd('new-session', '-d', '-P', '-F#{session_id}').stdout[0]
'$2'
>>> session.acmd('new-window', '-P').stdout[0]
'libtmux...:2.0'
>>> async def test_new_session():
... result = await server.acmd('new-session', '-d', '-P', '-F#{session_id}')
... print(result.stdout[0])
>>> asyncio.run(test_new_session())
$...
Output of `tmux -L ... new-window -P -F#{window_id}` to a `Window` object:
>>> Window.from_window_id(window_id=await session.acmd(
... 'new-window', '-P', '-F#{window_id}').stdout[0], server=session.server)
Window(@4 3:..., Session($1 libtmux_...))
>>> async def test_new_window():
... result = await server.acmd('new-window', '-P', '-F#{window_id}')
... window_id = result.stdout[0]
... window = Window.from_window_id(window_id=window_id, server=server)
... print(window)
>>> asyncio.run(test_new_window())
Window(@... ...:..., Session($... libtmux_...))
Create a pane from a window:
>>> window.acmd('split-window', '-P', '-F#{pane_id}').stdout[0]
'%5'
>>> async def test_split_window():
... result = await server.acmd('split-window', '-P', '-F#{pane_id}')
... print(result.stdout[0])
>>> asyncio.run(test_split_window())
%...
Output of `tmux -L ... split-window -P -F#{pane_id}` to a `Pane` object:
>>> Pane.from_pane_id(pane_id=window.cmd(
... 'split-window', '-P', '-F#{pane_id}').stdout[0], server=window.server)
>>> async def test_pane():
... result = await server.acmd('split-window', '-P', '-F#{pane_id}')
... pane_id = result.stdout[0]
... pane = Pane.from_pane_id(pane_id=pane_id, server=server)
... print(pane)
>>> asyncio.run(test_pane())
Pane(%... Window(@... ...:..., Session($1 libtmux_...)))
Parameters
Expand Down

0 comments on commit a19a9f0

Please sign in to comment.