|
5 | 5 | libtmux convenient access to move around the hierachy of sessions,
|
6 | 6 | windows and panes in tmux.
|
7 | 7 |
|
8 |
| -this is done by libtmux's object abstraction of {}`target`\_s (the `-t` |
9 |
| -command) and the permanent internal ID's tmux gives to objects. |
| 8 | +This is done by libtmux's object abstraction of {term}`target`s (the `-t` |
| 9 | +argument) and the permanent internal ID's tmux gives to objects. |
10 | 10 |
|
11 |
| -open two terminals: |
| 11 | +Open two terminals: |
12 | 12 |
|
13 |
| -terminal one: start tmux in a seperate terminal: |
| 13 | +Terminal one: start tmux in a seperate terminal: |
14 | 14 |
|
15 |
| -``` |
| 15 | +```console |
16 | 16 | $ tmux
|
17 | 17 | ```
|
18 | 18 |
|
19 |
| -terminal two, `python` or `ptpython` if you have it: |
| 19 | +Terminal two, `python` or `ptpython` if you have it: |
20 | 20 |
|
21 |
| -``` |
| 21 | +```console |
22 | 22 | $ python
|
23 | 23 | ```
|
24 | 24 |
|
25 |
| -import tmux: |
| 25 | +Import `libtmux`: |
26 | 26 |
|
27 |
| -``` |
28 |
| -import tmux |
| 27 | +```python |
| 28 | +import libtmux |
29 | 29 | ```
|
30 | 30 |
|
31 |
| -attach default tmux {class}`libtmux.Server` to `t`: |
| 31 | +Attach default tmux {class}`~libtmux.Server` to `t`: |
32 | 32 |
|
33 |
| -``` |
| 33 | +```python |
34 | 34 | >>> t = libtmux.Server();
|
35 | 35 | >>> t
|
36 | 36 | <libtmux.server.Server object at 0x10edd31d0>
|
37 | 37 | ```
|
38 | 38 |
|
39 |
| -get first session {class}`Session` to {}`session`: |
| 39 | +Get first session {class}`~libtmux.Session` to `session`: |
40 | 40 |
|
41 |
| -``` |
| 41 | +```python |
42 | 42 | >>> session = t.sessions[0]
|
43 | 43 | >>> session
|
44 | 44 | Session($0 libtmux)
|
45 | 45 | ```
|
46 | 46 |
|
47 |
| -get a list of sessions: |
| 47 | +Get a list of sessions: |
48 | 48 |
|
49 |
| -``` |
| 49 | +```python |
50 | 50 | >>> t.sessions
|
51 | 51 | [Session($0 libtmux), Session($1 tmuxp)]
|
52 | 52 | ```
|
53 | 53 |
|
54 |
| -iterate through sessions in a server: |
| 54 | +Iterate through sessions in a server: |
55 | 55 |
|
56 |
| -``` |
| 56 | +```python |
57 | 57 | >>> for sess in t.sessions:
|
58 | 58 | ... print(sess)
|
59 | 59 |
|
60 | 60 | Session($0 libtmux)
|
61 | 61 | Session($1 tmuxp)
|
62 | 62 | ```
|
63 | 63 |
|
64 |
| -grab a {class}`Window` from a session: |
| 64 | +Grab a {class}`~libtmux.Window` from a session: |
65 | 65 |
|
66 |
| -``` |
| 66 | +```python |
67 | 67 | >>> session.windows[0]
|
68 | 68 | Window(@1 1:libtmux, Session($0 libtmux))
|
69 | 69 | ```
|
70 | 70 |
|
71 |
| -grab the currently focused window from session: |
72 |
| - |
73 |
| -> > > > session.attached_window |
74 |
| -> > > > Window(@2 2:docs, Session($0 libtmux))grab the currently focused {class}`Pane` from session: |
| 71 | +Grab the currently focused window from session: |
75 | 72 |
|
| 73 | +```python |
| 74 | +>>> session.attached_window |
| 75 | +>>> Window(@2 2:docs, Session($0 libtmux))grab the currently focused {class}`Pane` from session: |
76 | 76 | ```
|
| 77 | + |
| 78 | +```python |
77 | 79 | >>> session.attached_pane
|
78 | 80 | Pane(%5 Window(@2 2:docs, Session($0 libtmux)))
|
79 | 81 | ```
|
80 | 82 |
|
81 |
| -assign the attached pane to `p`: |
| 83 | +Assign the attached {class}`~libtmux.Pane` to `p`: |
82 | 84 |
|
83 |
| -``` |
| 85 | +```python |
84 | 86 | >>> p = session.attached_pane
|
85 | 87 | ```
|
86 | 88 |
|
87 |
| -access the window/server of a pane: |
| 89 | +Access the window/server of a pane: |
88 | 90 |
|
89 |
| -``` |
| 91 | +```python |
90 | 92 | >>> p.window
|
91 | 93 | Window(@2 2:docs, Session($0 libtmux))
|
92 | 94 |
|
|
0 commit comments