Debian Codegraph @

docs/api/libtmux.neo.md

raw symbols SCIP
1 (properties)=
2
3 # Properties
4
5 Get access to the data attributes behind tmux sessions, windows and panes.
6
7 This is done through accessing the [formats][formats] available in `list-sessions`,
8 `list-windows` and `list-panes`.
9
10 Open two terminals:
11
12 Terminal one: start tmux in a separate terminal:
13
14 ```console
15 $ tmux
16 ```
17
18 Terminal two: `python` or `ptpython` if you have it:
19
20 ```console
21 $ python
22 ```
23
24 Import libtmux:
25
26 ```python
27 >>> import libtmux
28 ```
29
30 Attach default tmux {class}`~libtmux.Server` to `t`:
31
32 ```python
33 >>> import libtmux
34 >>> t = libtmux.Server()
35 >>> t
36 Server(socket_path=/tmp/tmux-.../default)
37 ```
38
39 ## Session
40
41 Get the {class}`~libtmux.Session` object:
42
43 ```python
44 >>> session = server.sessions[0]
45 >>> session
46 Session($1 libtmux_...)
47 ```
48
49 Quick access to basic attributes:
50
51 ```python
52 >>> session.session_name
53 'libtmux_...'
54
55 >>> session.session_id
56 '$1'
57 ```
58
59 Inspect field names on {class}`~libtmux.neo.Obj`:
60
61 ```python
62 >>> from libtmux.neo import Obj
63
64 >>> sorted(Obj.__dataclass_fields__)[:3]
65 ['active_window_index', 'alternate_saved_x', 'alternate_saved_y']
66 ```
67
68 ```python
69 >>> session.session_windows
70 '...'
71 ```
72
73 ## Windows
74
75 The same concepts apply for {class}`~libtmux.Window`:
76
77 ```python
78 >>> window = session.active_window
79
80 >>> window
81 Window(@1 ...:..., Session($1 ...))
82 ```
83
84 Basics:
85
86 ```python
87 >>> window.window_name
88 '...'
89
90 >>> window.window_id
91 '@1'
92
93 >>> window.window_height
94 '...'
95
96 >>> window.window_width
97 '...'
98 ```
99
100 Use attribute access for details not accessible via properties:
101
102 ```python
103 >>> window.window_panes
104 '1'
105 ```
106
107 ## Panes
108
109 Get the {class}`~libtmux.Pane`:
110
111 ```python
112 >>> pane = window.active_pane
113
114 >>> pane
115 Pane(%1 Window(@1 ...:..., Session($1 libtmux_...)))
116 ```
117
118 Basics:
119
120 ```python
121 >>> pane.pane_current_command
122 '...'
123
124 >>> type(pane.pane_current_command)
125 <class 'str'>
126
127 >>> pane.pane_height
128 '...'
129
130 >>> pane.pane_width
131 '...'
132
133 >>> pane.pane_index
134 '0'
135 ```
136
137 [formats]: http://man.openbsd.org/OpenBSD-5.9/man1/tmux.1#FORMATS