Skip to content

Commit 4082552

Browse files
committed
docs(README): make quickstart fully self-contained
1 parent 7e08ca5 commit 4082552

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,31 @@ libtmux==0.49.*
8282
libtmux = "0.49.*"
8383
```
8484

85-
## Quickstart
85+
## 🚀 Quickstart
8686

87-
Create and drive a tmux session from Python.
88-
89-
```console
90-
tmux new-session -s demo -n main
91-
```
87+
Create and drive a tmux session entirely from Python.
9288

9389
```python
9490
import libtmux
91+
import time
9592

93+
# Connect to the server (starts one if not running)
9694
server = libtmux.Server()
97-
session = server.sessions.get(session_name="demo")
9895

99-
window = session.new_window(attach=False, window_name="workspace")
96+
# Use a unique name to avoid conflicts if you run this multiple times
97+
session_name = f"libtmux-demo-{int(time.time())}"
98+
99+
# Create the session and the initial window
100+
session = server.new_session(session_name=session_name, window_name="workspace")
101+
102+
window = session.active_window
100103
left = window.active_pane
101104
right = window.split_window(vertical=True)
102105

103106
left.send_keys("vim", enter=True)
104107
right.send_keys("htop", enter=True)
105108

106-
print(f"Attach with: tmux attach -t {session.name}")
109+
print(f"✅ Session ready. Attach with: tmux attach -t {session_name}")
107110
```
108111

109112
## Core concepts

0 commit comments

Comments
 (0)