Blame

f62901 Thai Pangsakulyanont 2026-01-30 14:06:24 1
---
2
name: tmux
3
description: Use this skill to run background processes or long running processes using tmux.
4
---
5
6
`tmux` lets you run commands in the background and check on them later. When you run a normal bash command, you have to wait for it to finish. With tmux, you can start a command, let it run in the background, and check its output whenever you want.
7
8
Key Terms:
9
10
- Session: A container that holds your tabs. Like a browser window.
11
- Tab: A place where one command runs. Like a browser tab. We call this a "window" in tmux.
12
13
# Step 1: Create or Use a Session
14
15
Always do this first:
16
17
```bash
18
# Create a new session
19
tmux new-session -d -s mysession
20
```
21
22
- Use the project name (e.g. working directory basename) as the session name.
23
- If it fails with "duplicate session", it means the session already exists. It may be created by a prior session. You can use it, but check its state before continuing.
24
25
```bash
26
# See what sessions exist
27
tmux ls
28
29
# Delete a session when done
30
tmux kill-session -t mysession
31
```
32
33
# Step 2: Create Tabs (Windows)
34
35
```bash
36
# Create a tab called "mytab" in session "mysession"
37
tmux new-window -t mysession -n mytab
38
```
39
40
- Always give your tab a name. Don't use numbers.
41
- Always specify the session name in the command line as there may be multiple tmux sessions active.
42
43
```bash
44
# See what tabs exist
45
tmux list-windows -t mysession
46
47
# Delete a tab
48
tmux kill-window -t mysession:mytab
49
```
50
51
# Step 3: Run a Command in a Tab
52
53
```bash
54
# Run "npm start" in the "server" tab
55
tmux send-keys -t mysession:server 'npm start' Enter
56
```
57
58
- Always end with `Enter` to actually run the command.
59
60
```bash
61
# Stop a running command: Send Ctrl+C
62
tmux send-keys -t mysession:server C-c
63
```
64
65
Common stop signals:
66
- `C-c` = Ctrl+C (interrupt)
67
- `C-d` = Ctrl+D (end input)
68
69
# Step 4: Check What Happened
70
71
```bash
72
# See what's on screen now
73
tmux capture-pane -t mysession:server -p
74
```
75
c955d9 Thai Pangsakulyanont 2026-01-30 14:08:21 76
If you don't see the output you want yet, sleep and run again. If you don't know how long it will take, start at 15 seconds, doubling the sleep duration each time, but never sleep more than 4 minutes (240 seconds).