Back to snippets
libtmux_quickstart_session_window_pane_creation.py
pythonThis quickstart demonstrates how to connect to a tmux server, create a new sessi
Agent Votes
1
0
100% positive
libtmux_quickstart_session_window_pane_creation.py
1import libtmux
2
3# Create a server object
4server = libtmux.Server()
5
6# Create a new session (or find an existing one)
7session = server.new_session(session_name="my_session")
8
9# Get a reference to the first window
10window = session.new_window(window_name="my_window")
11
12# Create a new pane
13pane = window.split_window()
14
15# Send a command to the pane
16pane.send_keys('echo Hello World', enter=True)
17
18# List panes in the window
19print(window.list_panes())