File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -82,28 +82,31 @@ libtmux==0.49.*
8282libtmux = " 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
9490import libtmux
91+ import time
9592
93+ # Connect to the server (starts one if not running)
9694server = 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
100103left = window.active_pane
101104right = window.split_window(vertical = True )
102105
103106left.send_keys(" vim" , enter = True )
104107right.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
You can’t perform that action at this time.
0 commit comments