1
- """Pythonization of the :term:`tmux(1)` server.
1
+ """Wrapper for :term:`tmux(1)` server.
2
2
3
3
libtmux.server
4
4
~~~~~~~~~~~~~~
38
38
39
39
40
40
class Server (EnvironmentMixin ):
41
- """
42
- The :term:`tmux(1)` :term:`Server` [server_manual]_.
41
+ """:term:`tmux(1)` :term:`Server` [server_manual]_.
43
42
44
43
- :attr:`Server.sessions` [:class:`Session`, ...]
45
44
@@ -136,7 +135,7 @@ def __init__(
136
135
self .colors = colors
137
136
138
137
def is_alive (self ) -> bool :
139
- """If server alive or not .
138
+ """Return True if tmux server alive .
140
139
141
140
>>> tmux = Server(socket_name="no_exist")
142
141
>>> assert not tmux.is_alive()
@@ -175,8 +174,7 @@ def raise_if_dead(self) -> None:
175
174
# Command
176
175
#
177
176
def cmd (self , * args : t .Any , ** kwargs : t .Any ) -> tmux_cmd :
178
- """
179
- Execute tmux command and return output.
177
+ """Execute tmux command, rsepective of socket name and file, return output.
180
178
181
179
Examples
182
180
--------
@@ -212,8 +210,7 @@ def cmd(self, *args: t.Any, **kwargs: t.Any) -> tmux_cmd:
212
210
213
211
@property
214
212
def attached_sessions (self ) -> t .List [Session ]:
215
- """
216
- Return active :class:`Session` objects.
213
+ """Return active :class:`Session`s.
217
214
218
215
Examples
219
216
--------
@@ -242,8 +239,7 @@ def attached_sessions(self) -> t.List[Session]:
242
239
return attached_sessions
243
240
244
241
def has_session (self , target_session : str , exact : bool = True ) -> bool :
245
- """
246
- Return True if session exists. ``$ tmux has-session``.
242
+ """Return True if session exists.
247
243
248
244
Parameters
249
245
----------
@@ -275,12 +271,11 @@ def has_session(self, target_session: str, exact: bool = True) -> bool:
275
271
return False
276
272
277
273
def kill_server (self ) -> None :
278
- """``$ tmux kill- server`` ."""
274
+ """Kill tmux server."""
279
275
self .cmd ("kill-server" )
280
276
281
277
def kill_session (self , target_session : t .Union [str , int ]) -> "Server" :
282
- """
283
- Kill the tmux session with ``$ tmux kill-session``, return ``self``.
278
+ """Kill tmux session.
284
279
285
280
Parameters
286
281
----------
@@ -304,8 +299,7 @@ def kill_session(self, target_session: t.Union[str, int]) -> "Server":
304
299
return self
305
300
306
301
def switch_client (self , target_session : str ) -> None :
307
- """
308
- ``$ tmux switch-client``.
302
+ """Switch tmux client.
309
303
310
304
Parameters
311
305
----------
@@ -324,7 +318,7 @@ def switch_client(self, target_session: str) -> None:
324
318
raise exc .LibTmuxException (proc .stderr )
325
319
326
320
def attach_session (self , target_session : t .Optional [str ] = None ) -> None :
327
- """``$ tmux attach- session`` aka alias: ``$ tmux attach`` .
321
+ """Attach tmux session.
328
322
329
323
Parameters
330
324
----------
@@ -359,8 +353,7 @@ def new_session(
359
353
* args : t .Any ,
360
354
** kwargs : t .Any ,
361
355
) -> Session :
362
- """
363
- Return :class:`Session` from ``$ tmux new-session``.
356
+ """Create new session, returns new :class:`Session`.
364
357
365
358
Uses ``-P`` flag to print session info, ``-F`` for return formatting
366
359
returns new Session object.
@@ -498,7 +491,7 @@ def new_session(
498
491
#
499
492
@property
500
493
def sessions (self ) -> QueryList [Session ]: # type:ignore
501
- """Sessions belonging server.
494
+ """Sessions contained in server.
502
495
503
496
Can be accessed via
504
497
:meth:`.sessions.get() <libtmux._internal.query_list.QueryList.get()>` and
@@ -519,7 +512,7 @@ def sessions(self) -> QueryList[Session]: # type:ignore
519
512
520
513
@property
521
514
def windows (self ) -> QueryList [Window ]: # type:ignore
522
- """Windows belonging server.
515
+ """Windows contained in server's sessions .
523
516
524
517
Can be accessed via
525
518
:meth:`.windows.get() <libtmux._internal.query_list.QueryList.get()>` and
@@ -538,7 +531,7 @@ def windows(self) -> QueryList[Window]: # type:ignore
538
531
539
532
@property
540
533
def panes (self ) -> QueryList [Pane ]: # type:ignore
541
- """Panes belonging server.
534
+ """Panes contained in tmux server (across all windows in all sessions) .
542
535
543
536
Can be accessed via
544
537
:meth:`.panes.get() <libtmux._internal.query_list.QueryList.get()>` and
@@ -582,8 +575,7 @@ def __repr__(self) -> str:
582
575
# Legacy: Redundant stuff we want to remove
583
576
#
584
577
def _list_panes (self ) -> t .List [PaneDict ]:
585
- """
586
- Return list of panes in :py:obj:`dict` form.
578
+ """Return list of panes in :py:obj:`dict` form.
587
579
588
580
Retrieved from ``$ tmux(1) list-panes`` stdout.
589
581
@@ -599,8 +591,7 @@ def _list_panes(self) -> t.List[PaneDict]:
599
591
return [p .__dict__ for p in self .panes ]
600
592
601
593
def _update_panes (self ) -> "Server" :
602
- """
603
- Update internal pane data and return ``self`` for chainability.
594
+ """Update internal pane data and return ``self`` for chainability.
604
595
605
596
.. deprecated:: 0.16
606
597
0 commit comments