@@ -125,33 +125,33 @@ Windows and Panes.
125
125
If you have multiple tmux sessions open, you can see that all of the
126
126
methods in {class}` Server ` are available.
127
127
128
- We can list sessions with {meth}` Server.list_sessions ` :
128
+ We can list sessions with {meth}` Server.sessions ` :
129
129
130
130
``` python
131
- >> > server.list_sessions()
131
+ >> > server.sessions
132
132
[Session($ 1 ... ), Session($ 0 ... )]
133
133
```
134
134
135
135
This returns a list of {class}` Session ` objects you can grab. We can
136
136
find our current session with:
137
137
138
138
``` python
139
- >> > server.list_sessions() [0 ]
139
+ >> > server.sessions [0 ]
140
140
Session($ 1 ... )
141
141
```
142
142
143
143
However, this isn't guaranteed, libtmux works against current tmux information, the
144
144
session's name could be changed, or another tmux session may be created,
145
- so {meth}` Server.get_by_id ` and {meth}` Server.find_where ` exists as a lookup.
145
+ so {meth}` Server.sessions ` and {meth}` Server.windows ` exists as a lookup.
146
146
147
147
## Get session by ID
148
148
149
149
tmux sessions use the ` $[0-9] ` convention as a way to identify sessions.
150
150
151
- ` $1 ` is whatever the ID ` list_sessions ()` returned above.
151
+ ` $1 ` is whatever the ID ` sessions ()` returned above.
152
152
153
153
``` python
154
- >> > server.get_by_id( ' $1' )
154
+ >> > server.sessions.filter( session_id = ' $1' )[ 0 ]
155
155
Session($ 1 ... )
156
156
```
157
157
@@ -163,13 +163,16 @@ You may `session = server.get_by_id('$<yourId>')` to use the session object.
163
163
>> > server.sessions[0 ].rename_session(' foo' )
164
164
Session($ 1 foo)
165
165
166
- >> > server.find_where({ " session_name" : " foo" })
166
+ >> > server.sessions.filter(session_name = " foo" )[0 ]
167
+ Session($ 1 foo)
168
+
169
+ >> > server.sessions.get(session_name = " foo" )
167
170
Session($ 1 foo)
168
171
```
169
172
170
- With ` find_where ` , pass in a dict and return the first object found . In
173
+ With ` filter ` , pass in attributes and return a list of matches . In
171
174
this case, a {class}` Server ` holds a collection of child {class}` Session ` .
172
- {class}` Session ` and {class}` Window ` both utilize ` find_where ` to sift
175
+ {class}` Session ` and {class}` Window ` both utilize ` filter ` to sift
173
176
through Windows and Panes, respectively.
174
177
175
178
So you may now use:
@@ -178,7 +181,7 @@ So you may now use:
178
181
>> > server.sessions[0 ].rename_session(' foo' )
179
182
Session($ 1 foo)
180
183
181
- >> > session = server.find_where({ " session_name" : " foo" } )
184
+ >> > session = server.sessions.get( session_name = " foo" )
182
185
>> > session
183
186
Session($ 1 foo)
184
187
```
@@ -213,7 +216,7 @@ Let's delete that window ({meth}`Session.kill_window`).
213
216
Method 1: Use passthrough to tmux's ` target ` system.
214
217
215
218
``` python
216
- >> > session.kill_window(window.id )
219
+ >> > session.kill_window(window.window_id )
217
220
```
218
221
219
222
The window in the bg dissappeared. This was the equivalent of
@@ -260,7 +263,7 @@ And kill:
260
263
>> > window.kill_window()
261
264
```
262
265
263
- Use {meth}` Session.list_windows() ` and {meth}` Session.find_where () ` to list and sort
266
+ Use {meth}` Session.windows ` and {meth}` Session.windows.filter () ` to list and sort
264
267
through active {class}` Window ` 's.
265
268
266
269
## Manipulating windows
@@ -346,6 +349,7 @@ using {meth}`Pane.enter()`:
346
349
347
350
``` python
348
351
>> > pane.enter()
352
+ Pane(% 1 ... )
349
353
```
350
354
351
355
### Avoid cluttering shell history
0 commit comments