กลับไปหน้าสูตร
#tmux#terminal#command#cheatsheet
tmux Command Cheatsheet
รวมคำสั่ง tmux แบบใช้งานจริง: session, window, pane, copy mode, key bindings และ workflow สำหรับ dev
11 มีนาคม 2569อ่านประมาณ 2 นาที
สารบัญสูตร
Core Concepts
| Concept | ความหมาย |
|---|---|
| Session | workspace หลัก |
| Window | เหมือนแท็บ |
| Pane | split ใน window |
| Prefix | ปุ่มนำก่อนสั่งงาน (Ctrl+b ค่า default) |
Session Commands
| Command | ใช้ทำอะไร |
|---|---|
tmux | สร้าง session ใหม่ |
tmux new -s dev | สร้าง session ชื่อ dev |
tmux ls | ดู sessions |
tmux a -t dev | attach session dev |
tmux detach | detach ออกจาก session |
tmux kill-session -t dev | ลบ session |
tmux rename-session -t dev work | เปลี่ยนชื่อ session |
Window Commands
| Command | ใช้ทำอะไร |
|---|---|
Prefix + c | สร้าง window |
Prefix + n / p | ถัดไป / ก่อนหน้า |
Prefix + 0..9 | ไป window ตามเลข |
Prefix + , | rename window |
Prefix + & | ปิด window |
Prefix + w | list windows |
Pane Commands
| Command | ใช้ทำอะไร |
|---|---|
Prefix + % | split แนวตั้ง |
Prefix + " | split แนวนอน |
Prefix + o | สลับ pane |
Prefix + ; | สลับ pane ล่าสุด |
Prefix + x | ปิด pane |
Prefix + z | zoom pane |
Prefix + { / } | สลับตำแหน่ง pane |
Resize Panes
| Command | ใช้ทำอะไร |
|---|---|
Prefix + Ctrl + Arrow | resize pane |
Prefix + Alt + 1..5 | resize ตาม binding ที่ตั้งเอง (ถ้ามี) |
Copy Mode
| Command | ใช้ทำอะไร |
|---|---|
Prefix + [ | เข้า copy mode |
q | ออก copy mode |
Space | เริ่ม select |
Enter | copy selection |
Prefix + ] | paste |
Useful tmux.conf Snippet
set -g mouse on
set -g history-limit 100000
set -g base-index 1
setw -g pane-base-index 1
bind r source-file ~/.tmux.conf \; display "reloaded"
Daily Workflow
| Step | Action |
|---|---|
| สร้างงาน | tmux new -s project-a |
| แยก pane | code / server / logs |
| detach | Prefix + d |
| กลับมาทำต่อ | tmux a -t project-a |