@@ -7,195 +7,165 @@ Get access to the data attributions behind tmux sessions, windows and panes.
77This is done through accessing the [ formats] [ formats ] available in ` list-sessions ` ,
88` list-windows ` and ` list-panes ` .
99
10- open two terminals:
10+ Open two terminals:
1111
12- terminal one: start tmux in a seperate terminal:
12+ Terminal one: start tmux in a seperate terminal:
1313
14- ```
14+ ``` console
1515$ tmux
1616```
1717
18- terminal two, ` python ` or ` ptpython ` if you have it:
18+ Terminal two: ` python ` or ` ptpython ` if you have it:
1919
2020``` console
21-
2221$ python
23-
2422```
2523
26- import tmux:
27-
28- ``` {code-block} python
29-
30- import tmux
24+ Import libtmux:
3125
26+ ``` python
27+ import libtmux
3228```
3329
34- attach default tmux {class}` libtmux.Server ` to ` t ` :
30+ Attach default tmux {class}` ~ libtmux.Server` to ` t ` :
3531
36- ``` {code-block} python
37-
38- >>> t = libtmux.Server();
32+ ``` python
33+ >> > t = libtmux.Server()
3934>> > t
4035< libtmux.server.Server object at 0x 10edd31d0>
41-
4236```
4337
4438## Session
4539
46- get the ` session ` object:
47-
48- ``` {code-block} python
40+ Get the {class}` ~libtmux.Session ` object:
4941
42+ ``` python
5043>> > session = t.sessions[0 ]
51-
5244>> > session
5345Session($ 0 libtmux)
54-
5546```
5647
57- quick access to basic attributes:
58-
59- ``` {code-block} python
48+ Quick access to basic attributes:
6049
50+ ``` python
6151>> > session.name
62- u 'libtmux'
52+ ' libtmux'
6353
6454>> > session.id
65- u '$0'
55+ ' $0'
6656
6757>> > session.width
68- u '213'
58+ ' 213'
6959
7060>> > session.height
71- u'114'
72-
61+ ' 114'
7362```
7463
75- to see all attributes for a session:
76-
77- ``` {code-block} python
64+ To see all attributes for a session:
7865
66+ ``` python
7967>> > session._info.keys()
80- [u 'session_height', u 'session_windows', u 'session_width', u 'session_id', u 'session_created', u 'session_attached', u 'session_grouped', u 'session_name']
68+ [' session_height' , ' session_windows' , ' session_width' , ' session_id' , ' session_created' , ' session_attached' , ' session_grouped' , ' session_name' ]
8169
8270>> > session._info
83- {u 'session_height': u '114', u 'session_windows': u '3', u 'session_width': u '213', u 'session_id': u '$0', u 'session_created': u '1464905357', u 'session_attached': u '1', u 'session_grouped': u '0', u 'session_name': u 'libtmux'}
71+ {' session_height' : ' 114' , ' session_windows' : ' 3' , ' session_width' : ' 213' , ' session_id' : ' $0' , ' session_created' : ' 1464905357' , ' session_attached' : ' 1' , ' session_grouped' : ' 0' , ' session_name' : ' libtmux' }
8472
8573```
8674
87- some may conflict with python API, to access them, you can use ` .get() ` , to get the count
75+ Some may conflict with python API, to access them, you can use ` .get() ` , to get the count
8876of sessions in a window:
8977
90- ``` {code-block} python
91-
78+ ``` python
9279>> > session.get(' session_windows' )
93- u'3'
94-
80+ ' 3'
9581```
9682
9783## Windows
9884
99- The same concepts apply for window:
100-
101- ``` {code-block} python
85+ The same concepts apply for {class}` ~libtmux.Window ` :
10286
87+ ``` python
10388>> > window = session.attached_window
10489
10590>> > window
10691Window(@ 2 2 :docs, Session($ 0 libtmux))
107-
10892```
10993
110- basics:
111-
112- ``` {code-block} python
94+ Basics:
11395
96+ ``` python
11497>> > window.name
115- u 'docs'
98+ ' docs'
11699
117100>> > window.id
118- u '@2'
101+ ' @2'
119102
120103>> > window.height
121- u '114'
104+ ' 114'
122105
123106>> > window.width
124- u'213'
125-
107+ ' 213'
126108```
127109
128- everything available:
129-
130- ``` {code-block} python
110+ Everything available:
131111
112+ ``` python
132113>> > window._info
133- {u 'window_panes': u '4', u 'window_active': u '1', u 'window_height': u '114', u 'window_activity_flag': u '0', u 'window_width': u '213', u 'session_id': u '$0', u 'window_id': u '@2', u 'window_layout': u 'dad5,213x114,0,0[213x60,0,0,4,213x53,0,61{70x53,0,61,5,70x53,71,61,6,71x53,142,61,7}]', u 'window_silence_flag': u '0', u 'window_index': u '2', u 'window_bell_flag': u '0', u 'session_name': u 'libtmux', u 'window_flags': u '*', u 'window_name': u 'docs'}
114+ {' window_panes' : ' 4' , ' window_active' : ' 1' , ' window_height' : ' 114' , ' window_activity_flag' : ' 0' , ' window_width' : ' 213' , ' session_id' : ' $0' , ' window_id' : ' @2' , ' window_layout' : ' dad5,213x114,0,0[213x60,0,0,4,213x53,0,61{70x53,0,61,5,70x53,71,61,6,71x53,142,61,7}]' , ' window_silence_flag' : ' 0' , ' window_index' : ' 2' , ' window_bell_flag' : ' 0' , ' session_name' : ' libtmux' , ' window_flags' : ' *' , ' window_name' : ' docs' }
134115
135116>> > window.keys()
136- [u'window_panes', u'window_active', u'window_height', u'window_activity_flag', u'window_width', u'session_id', u'window_id', u'window_layout', u'window_silence_flag', u'window_index', u'window_bell_flag', u'session_name', u'window_flags', u'window_name']
137-
117+ [' window_panes' , ' window_active' , ' window_height' , ' window_activity_flag' , ' window_width' , ' session_id' , ' window_id' , ' window_layout' , ' window_silence_flag' , ' window_index' , ' window_bell_flag' , ' session_name' , ' window_flags' , ' window_name' ]
138118```
139119
140- use ` get() ` for details not accessible via properties:
141-
142- ``` {code-block} python
120+ Use ` get() ` for details not accessible via properties:
143121
122+ ``` python
144123>> > pane.get(' window_panes' )
145- u'4'
146-
124+ ' 4'
147125```
148126
149127## Panes
150128
151- get the pane:
152-
153- ``` {code-block} python
129+ Get the {class}` ~libtmux.Pane ` :
154130
131+ ``` python
155132>> > pane = window.attached_pane
156133
157134>> > pane
158135Pane(% 5 Window(@ 2 2 :docs, Session($ 0 libtmux)))
159-
160136```
161137
162- basics:
163-
164- ``` {code-block} python
138+ Basics:
165139
140+ ``` python
166141>> > pane.current_command
167- u 'python'
142+ ' python'
168143
169144>> > pane.height
170- u '53'
145+ ' 53'
171146
172147>> > pane.width
173- u '70'
148+ ' 70'
174149
175150>> > pane.index
176- u'1'
177-
151+ ' 1'
178152```
179153
180- everything:
181-
182- ``` {code-block} python
154+ Everything:
183155
156+ ``` python
184157>> > pane._info
185- {u 'alternate_saved_x': u '0', u 'alternate_saved_y': u '0', u 'cursor_y': u '47', u 'cursor_x': u '0', u 'pane_in_mode': u '0', u 'insert_flag': u '0', u 'keypad_flag': u '0', u 'cursor_flag': u '1', u 'pane_current_command': u 'python', u 'window_index': u '2', u 'history_size': u '216', u 'scroll_region_lower': u '52', u 'keypad_cursor_flag': u '0', u 'history_bytes': u '38778', u 'pane_active': u '1', u 'pane_dead': u '0', u 'pane_synchronized': u '0', u 'window_id': u '@2', u 'pane_index': u '1', u 'pane_width': u '70', u 'mouse_any_flag': u '0', u 'mouse_button_flag': u '0', u 'window_name': u 'docs', u 'pane_current_path': u '/Users/me/work/python/libtmux/doc', u 'pane_tty': u '/dev/ttys007', u 'pane_title': u 'Python REPL (ptpython)', u 'session_id': u '$0', u 'alternate_on': u '0', u 'mouse_standard_flag': u '0', u 'wrap_flag': u '1', u 'history_limit': u '2000', u 'pane_pid': u '37172', u 'pane_height': u '53', u 'session_name': u 'libtmux', u 'scroll_region_upper': u '0', u 'pane_id': u '%5'}
158+ {' alternate_saved_x' : ' 0' , ' alternate_saved_y' : ' 0' , ' cursor_y' : ' 47' , ' cursor_x' : ' 0' , ' pane_in_mode' : ' 0' , ' insert_flag' : ' 0' , ' keypad_flag' : ' 0' , ' cursor_flag' : ' 1' , ' pane_current_command' : ' python' , ' window_index' : ' 2' , ' history_size' : ' 216' , ' scroll_region_lower' : ' 52' , ' keypad_cursor_flag' : ' 0' , ' history_bytes' : ' 38778' , ' pane_active' : ' 1' , ' pane_dead' : ' 0' , ' pane_synchronized' : ' 0' , ' window_id' : ' @2' , ' pane_index' : ' 1' , ' pane_width' : ' 70' , ' mouse_any_flag' : ' 0' , ' mouse_button_flag' : ' 0' , ' window_name' : ' docs' , ' pane_current_path' : ' /Users/me/work/python/libtmux/doc' , ' pane_tty' : ' /dev/ttys007' , ' pane_title' : ' Python REPL (ptpython)' , ' session_id' : ' $0' , ' alternate_on' : ' 0' , ' mouse_standard_flag' : ' 0' , ' wrap_flag' : ' 1' , ' history_limit' : ' 2000' , ' pane_pid' : ' 37172' , ' pane_height' : ' 53' , ' session_name' : ' libtmux' , ' scroll_region_upper' : ' 0' , ' pane_id' : ' %5' }
186159
187160>> > pane._info.keys()
188- [u'alternate_saved_x', u'alternate_saved_y', u'cursor_y', u'cursor_x', u'pane_in_mode', u'insert_flag', u'keypad_flag', u'cursor_flag', u'pane_current_command', u'window_index', u'history_size', u'scroll_region_lower', u'keypad_cursor_flag', u'history_bytes', u'pane_active', u'pane_dead', u'pane_synchronized', u'window_id', u'pane_index', u'pane_width', u'mouse_any_flag', u'mouse_button_flag', u'window_name', u'pane_current_path', u'pane_tty', u'pane_title', u'session_id', u'alternate_on', u'mouse_standard_flag', u'wrap_flag', u'history_limit', u'pane_pid', u'pane_height', u'session_name', u'scroll_region_upper', u'pane_id']
189-
161+ [' alternate_saved_x' , ' alternate_saved_y' , ' cursor_y' , ' cursor_x' , ' pane_in_mode' , ' insert_flag' , ' keypad_flag' , ' cursor_flag' , ' pane_current_command' , ' window_index' , ' history_size' , ' scroll_region_lower' , ' keypad_cursor_flag' , ' history_bytes' , ' pane_active' , ' pane_dead' , ' pane_synchronized' , ' window_id' , ' pane_index' , ' pane_width' , ' mouse_any_flag' , ' mouse_button_flag' , ' window_name' , ' pane_current_path' , ' pane_tty' , ' pane_title' , ' session_id' , ' alternate_on' , ' mouse_standard_flag' , ' wrap_flag' , ' history_limit' , ' pane_pid' , ' pane_height' , ' session_name' , ' scroll_region_upper' , ' pane_id' ]
190162```
191163
192- use ` get() ` for details keys:
193-
194- ``` {code-block} python
164+ Use ` get() ` for details keys:
195165
166+ ``` python
196167>> > pane.get(' pane_width' )
197- u'70'
198-
168+ ' 70'
199169```
200170
201171[ formats ] : http://man.openbsd.org/OpenBSD-5.9/man1/tmux.1#FORMATS
0 commit comments