Skip to content

Commit 7547e9c

Browse files
committed
docs(Server.cmd): Add examples
1 parent 5a86a95 commit 7547e9c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/libtmux/server.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,31 @@ def cmd(self, *args: t.Any, **kwargs: t.Any) -> tmux_cmd:
181181
>>> server.cmd('display-message', 'hi')
182182
<libtmux.common.tmux_cmd object at ...>
183183
184+
New session:
185+
186+
>>> server.cmd('new-session', '-d', '-P', '-F#{session_id}').stdout[0]
187+
'$2'
188+
189+
>>> session.cmd('new-window', '-P').stdout[0]
190+
'libtmux...:2.0'
191+
192+
Time for some tech, direct to a rich, `Window` object:
193+
194+
>>> Window.from_window_id(window_id=session.cmd(
195+
... 'new-window', '-P', '-F#{window_id}').stdout[0], server=session.server)
196+
Window(@4 3:..., Session($1 libtmux_...))
197+
198+
Create a pane from a window:
199+
200+
>>> window.cmd('split-window', '-P', '-F#{pane_id}').stdout[0]
201+
'%5'
202+
203+
Magic, directly to a `Pane`:
204+
205+
>>> Pane.from_pane_id(pane_id=session.cmd(
206+
... 'split-window', '-P', '-F#{pane_id}').stdout[0], server=session.server)
207+
Pane(%... Window(@... ...:..., Session($1 libtmux_...)))
208+
184209
Returns
185210
-------
186211
:class:`common.tmux_cmd`

0 commit comments

Comments
 (0)