Skip to content

Commit 84058da

Browse files
committed
docs(quickstart): Clean up myst markdown
1 parent 6e31788 commit 84058da

File tree

1 file changed

+25
-66
lines changed

1 file changed

+25
-66
lines changed

docs/quickstart.md

Lines changed: 25 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ from inside a live tmux session.
1212

1313
## Requirements
1414

15-
- [tmux][tmux]
16-
- [pip][pip] - for this handbook's examples
15+
- [tmux]
16+
- [pip] - for this handbook's examples
1717

1818
[pip]: https://pip.pypa.io/en/stable/installing/
1919

@@ -26,9 +26,7 @@ from inside a live tmux session.
2626
Next, ensure `libtmux` is installed:
2727

2828
```console
29-
3029
$ pip install --user libtmux
31-
3230
```
3331

3432
(developmental-releases)=
@@ -106,13 +104,11 @@ $ ptpython
106104

107105
First, we can grab a {class}`Server`.
108106

109-
```{code-block} python
110-
107+
```python
111108
>>> import libtmux
112109
>>> server = libtmux.Server()
113110
>>> server
114111
<libtmux.server.Server object at 0x7fbd622c1dd0>
115-
116112
```
117113

118114
:::{tip}
@@ -126,11 +122,9 @@ current tmux server / session / window pane.
126122
:::
127123

128124
:::{note}
129-
130125
You can specify a `socket_name`, `socket_path` and `config_file`
131126
in your server object. `libtmux.Server(socket_name='mysocket')` is
132127
equivalent to `$ tmux -L mysocket`.
133-
134128
:::
135129

136130
`server` is now a living object bound to the tmux server's Sessions,
@@ -143,20 +137,16 @@ methods in {class}`Server` are available.
143137

144138
We can list sessions with {meth}`Server.list_sessions`:
145139

146-
```{code-block} python
147-
140+
```python
148141
>>> server.list_sessions()
149142
[Session($3 foo), Session($1 libtmux)]
150-
151143
```
152144

153145
This returns a list of {class}`Session` objects you can grab. We can
154146
find our current session with:
155147

156-
```{code-block} python
157-
148+
```python
158149
>>> server.list_sessions()[0]
159-
160150
```
161151

162152
However, this isn't guaranteed, libtmux works against current tmux information, the
@@ -169,22 +159,18 @@ tmux sessions use the `$[0-9]` convention as a way to identify sessions.
169159

170160
`$3` is whatever the ID `list_sessions()` returned above.
171161

172-
```{code-block} python
173-
162+
```python
174163
>>> server.get_by_id('$3')
175164
Session($3 foo)
176-
177165
```
178166

179167
You may `session = server.get_by_id('$<yourId>')` to use the session object.
180168

181169
## Get session by name / other properties
182170

183-
```{code-block} python
184-
171+
```python
185172
>>> server.find_where({ "session_name": "foo" })
186173
Session($3 foo)
187-
188174
```
189175

190176
With `find_where`, pass in a dict and return the first object found. In
@@ -194,10 +180,8 @@ through Windows and Panes, respectively.
194180

195181
So you may now use:
196182

197-
```{code-block} python
198-
183+
```python
199184
>>> session = server.find_where({ "session_name": "foo" })
200-
201185
```
202186

203187
to give us a `session` object to play with.
@@ -209,11 +193,9 @@ available in {class}`Session`.
209193

210194
Let's make a {meth}`Session.new_window`, in the background:
211195

212-
```{code-block} python
213-
196+
```python
214197
>>> session.new_window(attach=False, window_name="ha in the bg")
215198
Window(@8 2:ha in the bg, Session($3 foo))
216-
217199
```
218200

219201
So a few things:
@@ -224,19 +206,15 @@ So a few things:
224206
3. Returns the {class}`Window` object created.
225207

226208
:::{note}
227-
228209
Use the API reference {ref}`api` for more commands.
229-
230210
:::
231211

232212
Let's delete that window ({meth}`Session.kill_window`).
233213

234214
Method 1: Use passthrough to tmux's `target` system.
235215

236-
```{code-block} python
237-
216+
```python
238217
>>> session.kill_window("ha in")
239-
240218
```
241219

242220
The window in the bg dissappeared. This was the equivalent of
@@ -254,37 +232,29 @@ target-window, or target-pane.
254232
In this case, you can also go back in time and recreate the window again. The CLI
255233
should have history, so navigate up with the arrow key.
256234

257-
```{code-block} python
258-
235+
```python
259236
>>> session.new_window(attach=False, window_name="ha in the bg")
260237
Window(@11 3:ha in the bg, Session($3 foo))
261-
262238
```
263239

264240
Try to kill the window by the matching id `@[0-9999]`.
265241

266-
```{code-block} python
267-
242+
```python
268243
>>> session.new_window(attach=False, window_name="ha in the bg")
269244
Window(@12 3:ha in the bg, Session($3 foo))
270-
271245
```
272246

273247
In addition, you could also `.kill_window` direction from the {class}`Window`
274248
object:
275249

276-
```{code-block} python
277-
250+
```python
278251
>>> window = session.new_window(attach=False, window_name="check this out")
279-
280252
```
281253

282254
And kill:
283255

284-
```{code-block} python
285-
256+
```python
286257
>>> window.kill_window()
287-
288258
```
289259

290260
Use {meth}`Session.list_windows()` and {meth}`Session.find_where()` to list and sort
@@ -295,21 +265,17 @@ through active {class}`Window`'s.
295265
Now that we know how to create windows, let's use one. Let's use {meth}`Session.attached_window()`
296266
to grab our current window.
297267

298-
```{code-block} python
299-
268+
```python
300269
>>> window = session.attached_window()
301-
302270
```
303271

304272
`window` now has access to all of the objects inside of {class}`Window`.
305273

306274
Let's create a pane, {meth}`Window.split_window`:
307275

308-
```{code-block} python
309-
276+
```python
310277
>>> window.split_window(attach=False)
311278
Pane(%23 Window(@10 1:bar, Session($3 foo)))
312-
313279
```
314280

315281
Powered up. Let's have a break down:
@@ -320,11 +286,9 @@ Powered up. Let's have a break down:
320286

321287
Also, since you are aware of this power, let's commemorate the experience:
322288

323-
```{code-block} python
324-
289+
```python
325290
>>> window.rename_window('libtmuxower')
326291
Window(@10 1:libtmuxower, Session($3 foo))
327-
328292
```
329293

330294
You should have noticed {meth}`Window.rename_window` renamed the window.
@@ -335,21 +299,20 @@ You have two ways you can move your cursor to new sessions, windows and panes.
335299

336300
For one, arguments such as `attach=False` can be omittted.
337301

338-
```{code-block} python
339-
302+
```python
340303
>>> pane = window.split_window()
341-
342304
```
343305

344306
This gives you the {class}`Pane` along with moving the cursor to a new window. You
345307
can also use the `.select_*` available on the object, in this case the pane has
346308
{meth}`Pane.select_pane()`.
347309

348-
```{code-block} python
349-
310+
```python
350311
>>> pane = window.split_window(attach=False)
351-
>>> pane.select_pane()
312+
```
352313

314+
```python
315+
>>> pane.select_pane()
353316
```
354317

355318
```{eval-rst}
@@ -365,12 +328,10 @@ can also use the `.select_*` available on the object, in this case the pane has
365328
You may send commands to panes, windows and sessions **without** them being visible.
366329
As long as you have the object, or are iterating through a list of them, you can use `.send_keys`.
367330

368-
```{code-block} python
369-
331+
```python
370332
>>> window = session.new_window(attach=False, window_name="test")
371333
>>> pane = window.split_window(attach=False)
372334
>>> pane.send_keys('echo hey', enter=False)
373-
374335
```
375336

376337
See the other window, notice that {meth}`Pane.send_keys` has " `echo hey`" written,
@@ -380,10 +341,8 @@ _still in the prompt_. Note the leading space character so the command won't be
380341
you may leave it to the user to press return himself, or complete a command
381342
using {meth}`Pane.enter()`:
382343

383-
```{code-block} python
384-
344+
```python
385345
>>> pane.enter()
386-
387346
```
388347

389348
## Final notes
@@ -398,7 +357,7 @@ sessions in the background. :)
398357
:::{seealso}
399358

400359
If you want to dig deeper, check out {ref}`API`, the code for
401-
and our [test suite][test suite] (see {ref}`developing`.)
360+
and our [test suite] (see {ref}`developing`.)
402361

403362
:::
404363

0 commit comments

Comments
 (0)