@@ -108,7 +108,7 @@ First, we can grab a {class}`Server`.
108108>> > import libtmux
109109>> > server = libtmux.Server()
110110>> > server
111- < libtmux.server.Server object at 0x 7fbd622c1dd0 >
111+ < libtmux.server.Server object at ... >
112112```
113113
114114:::{tip}
@@ -139,14 +139,15 @@ We can list sessions with {meth}`Server.list_sessions`:
139139
140140``` python
141141>> > server.list_sessions()
142- [Session($ 3 foo ), Session($ 1 libtmux )]
142+ [Session($ ... ... ), Session($ ... ... )]
143143```
144144
145145This returns a list of {class}` Session ` objects you can grab. We can
146146find our current session with:
147147
148148``` python
149149>> > server.list_sessions()[0 ]
150+ Session($ ... ... )
150151```
151152
152153However, this isn't guaranteed, libtmux works against current tmux information, the
@@ -157,20 +158,24 @@ so {meth}`Server.get_by_id` and {meth}`Server.find_where` exists as a lookup.
157158
158159tmux sessions use the ` $[0-9] ` convention as a way to identify sessions.
159160
160- ` $3 ` is whatever the ID ` list_sessions() ` returned above.
161+ ` $1 ` is whatever the ID ` list_sessions() ` returned above.
161162
162163``` python
163- >> > server.get_by_id(' $3 ' )
164- Session($ 3 foo )
164+ >> > server.get_by_id(' $1 ' )
165+ Session($ ... ... )
165166```
166167
167168You may ` session = server.get_by_id('$<yourId>') ` to use the session object.
168169
169170## Get session by name / other properties
170171
171172``` python
173+ # Just for setting up the example:
174+ >> > server.sessions[0 ].rename_session(' foo' )
175+ Session($ ... foo)
176+
172177>> > server.find_where({ " session_name" : " foo" })
173- Session($ 3 foo)
178+ Session($ ... foo)
174179```
175180
176181With ` find_where ` , pass in a dict and return the first object found. In
@@ -181,7 +186,13 @@ through Windows and Panes, respectively.
181186So you may now use:
182187
183188``` python
189+ # Prepping the example:
190+ >> > server.sessions[0 ].rename_session(' foo' )
191+ Session($ ... foo)
192+
184193>> > session = server.find_where({ " session_name" : " foo" })
194+ >> > session
195+ Session($ ... foo)
185196```
186197
187198to give us a ` session ` object to play with.
@@ -195,7 +206,7 @@ Let's make a {meth}`Session.new_window`, in the background:
195206
196207``` python
197208>> > session.new_window(attach = False , window_name = " ha in the bg" )
198- Window(@ 8 2 :ha in the bg, Session($ 3 foo ))
209+ Window(@ ... ... :ha in the bg, Session($ ... ... ))
199210```
200211
201212So a few things:
@@ -214,7 +225,7 @@ Let's delete that window ({meth}`Session.kill_window`).
214225Method 1: Use passthrough to tmux's ` target ` system.
215226
216227``` python
217- >> > session.kill_window(" ha in " )
228+ >> > session.kill_window(window.id )
218229```
219230
220231The window in the bg dissappeared. This was the equivalent of
@@ -234,21 +245,26 @@ should have history, so navigate up with the arrow key.
234245
235246``` python
236247>> > session.new_window(attach = False , window_name = " ha in the bg" )
237- Window(@ 11 3 :ha in the bg, Session($ 3 foo ))
248+ Window(@ ... ... :ha in the bg, Session($ ... ... ))
238249```
239250
240251Try to kill the window by the matching id ` @[0-9999] ` .
241252
242253``` python
254+ # Setup
243255>> > session.new_window(attach = False , window_name = " ha in the bg" )
244- Window(@ 12 3 :ha in the bg, Session($ 3 foo))
256+ Window(@ ... ... :ha in the bg, Session($ ... ... ))
257+
258+ >> > session.kill_window(' ha in the bg' )
245259```
246260
247261In addition, you could also ` .kill_window ` direction from the {class}` Window `
248262object:
249263
250264``` python
251265>> > window = session.new_window(attach = False , window_name = " check this out" )
266+ >> > window
267+ Window(@ ... ... :check this out, Session($ ... ... ))
252268```
253269
254270And kill:
@@ -266,7 +282,7 @@ Now that we know how to create windows, let's use one. Let's use {meth}`Session.
266282to grab our current window.
267283
268284``` python
269- >> > window = session.attached_window()
285+ >> > window = session.attached_window
270286```
271287
272288` window ` now has access to all of the objects inside of {class}` Window ` .
@@ -275,7 +291,7 @@ Let's create a pane, {meth}`Window.split_window`:
275291
276292``` python
277293>> > window.split_window(attach = False )
278- Pane(% 23 Window(@ 10 1 :bar , Session($ 3 foo )))
294+ Pane(% ... Window(@ ... ... : ... , Session($ ... ... )))
279295```
280296
281297Powered up. Let's have a break down:
@@ -288,7 +304,7 @@ Also, since you are aware of this power, let's commemorate the experience:
288304
289305``` python
290306>> > window.rename_window(' libtmuxower' )
291- Window(@ 10 1 :libtmuxower , Session($ 3 foo ))
307+ Window(@ ... ... : ... , Session($ ... ... ))
292308```
293309
294310You should have noticed {meth}` Window.rename_window ` renamed the window.
@@ -313,6 +329,7 @@ can also use the `.select_*` available on the object, in this case the pane has
313329
314330``` python
315331>> > pane.select_pane()
332+ Pane(% ... Window(@ ... ... :... , Session($ ... ... )))
316333```
317334
318335``` {eval-rst}
0 commit comments