Skip to content

Latest commit

 

History

History
137 lines (93 loc) · 1.87 KB

properties.md

File metadata and controls

137 lines (93 loc) · 1.87 KB

(properties)=

Properties

Get access to the data attributions behind tmux sessions, windows and panes.

This is done through accessing the formats available in list-sessions, list-windows and list-panes.

Open two terminals:

Terminal one: start tmux in a seperate terminal:

$ tmux

Terminal two: python or ptpython if you have it:

$ python

Import libtmux:

>>> import libtmux

Attach default tmux {class}~libtmux.Server to t:

>>> import libtmux
>>> t = libtmux.Server()
>>> t
<libtmux.server.Server object at ...>

Session

Get the {class}~libtmux.Session object:

>>> session = server.sessions[0]
>>> session
Session($1 libtmux_...)

Quick access to basic attributes:

>>> session.session_name
'libtmux_...'

>>> session.session_id
'$1'

To see all attributes for a session:

from libtmux.neo import Obj

>>> sorted(list(Obj.__dataclass_fields__.keys()))
['session_attached', 'session_created', ...]
>>> session.session_windows
'...'

Windows

The same concepts apply for {class}~libtmux.Window:

>>> window = session.attached_window

>>> window
Window(@1 ...:..., Session($1 ...))

Basics:

>>> window.window_name
'...'

>>> window.window_id
'@1'

>>> window.window_height
'...'

>>> window.window_width
'...'

Use attribute access for details not accessible via properties:

>>> window.window_panes
'1'

Panes

Get the {class}~libtmux.Pane:

>>> pane = window.attached_pane

>>> pane
Pane(%1 Window(@1 ...:..., Session($1 libtmux_...)))

Basics:

>>> pane.pane_current_command
'...'

>>> type(pane.pane_current_command)
<class 'str'>

>>> pane.pane_height
'...'

>>> pane.pane_width
'...'

>>> pane.pane_index
'0'