Post

🧷 tmux 정리본 (Cheat Sheet + μ‚¬μš© κ°€μ΄λ“œ)

터미널을 μ—¬λŸ¬κ°œμ˜ μ„Έμ…˜μœΌλ‘œ λ‚˜λˆ„μ–΄μ„œ μ‚¬μš©ν•  수 있게 ν•΄μ£ΌλŠ” tmux μ‚¬μš©λ²•μ— λŒ€ν•œ λ‚΄μš©

🧷 tmux 정리본 (Cheat Sheet + μ‚¬μš© κ°€μ΄λ“œ)

🧷 tmux 정리본 (Cheat Sheet + μ‚¬μš© κ°€μ΄λ“œ)

tmuxλŠ” μ—¬λŸ¬ 개의 터미널 μ„Έμ…˜μ„ μƒμ„±ν•˜κ³  관리할 수 있게 ν•΄μ£ΌλŠ” 터미널 λ©€ν‹°ν”Œλ ‰μ„œμ΄λ‹€. ν•œ μ„Έμ…˜ μ•ˆμ— μ—¬λŸ¬ 개의 μœˆλ„μš°(window) β†’ νŒ¨λ„(pane) 을 λ‘˜ 수 μžˆλ‹€.

ꡬ쑰: μ„Έμ…˜(Session) > μœˆλ„μš°(Window) > νŒ¨λ„(Pane)


1. μ„€μΉ˜

1
2
3
brew install tmux         # macOS
sudo apt-get install tmux # Ubuntu
sudo yum install tmux     # CentOS

2. μ„€μ • 파일

tmux 섀정은 ~/.tmux.conf 에 μž‘μ„±ν•œλ‹€. tmux μ‹€ν–‰ μ‹œ μžλ™ λ‘œλ“œλ˜λ©°, μž¬λ‘œλ“œλŠ” μ•„λž˜ λͺ…λ Ήμ–΄λ‘œ κ°€λŠ₯:

1
tmux source-file ~/.tmux.conf

3. κΈ°λ³Έ μ‚¬μš©λ²•

πŸ“Œ μ„Έμ…˜(Session)

● μ„Έμ…˜ 생성

1
2
3
4
tmux
tmux new
tmux new-session
tmux new -s sessionname

● μ„Έμ…˜ 접속

1
2
3
4
tmux attach
tmux attach-session
tmux a
tmux a -t sessionname

● μ„Έμ…˜ μ’…λ£Œ

1
2
tmux kill-session
tmux kill-session -t sessionname

● 자주 μ“°λŠ” 단좕킀

단좕킀섀λͺ…
Ctrl+b + $μ„Έμ…˜ 이름 λ³€κ²½
Ctrl+b + dμ„Έμ…˜ detach
Ctrl+b + )λ‹€μŒ μ„Έμ…˜
Ctrl+b + (이전 μ„Έμ…˜
Ctrl+b + wμ„Έμ…˜/μ°½ 리슀트 보기

4. μœˆλ„μš°(Window)

λΈŒλΌμš°μ € νƒ­μ²˜λŸΌ ν•˜λ‚˜μ˜ μ„Έμ…˜ μ•ˆμ—μ„œ μ—¬λŸ¬ 창을 μ‚¬μš©ν•  수 μžˆλ‹€.

● 단좕킀

단좕킀섀λͺ…
Ctrl+b + cμƒˆ μœˆλ„μš° 생성
Ctrl+b + nλ‹€μŒ μœˆλ„μš°
Ctrl+b + p이전 μœˆλ„μš°
Ctrl+b + lλ§ˆμ§€λ§‰μœΌλ‘œ μ‚¬μš©ν•œ μœˆλ„μš°
Ctrl+b + 숫자번호둜 이동
Ctrl+b + 'μ΄λ¦„μœΌλ‘œ κ²€μƒ‰ν•˜μ—¬ 이동
Ctrl+b + ,μœˆλ„μš° 이름 λ³€κ²½
Ctrl+b + .μœˆλ„μš° 번호 λ³€κ²½
Ctrl+b + &μœˆλ„μš° μ’…λ£Œ
Ctrl+b + fμœˆλ„μš° 검색
Ctrl+b + zνŒ¨λ„ ν™•λŒ€/μΆ•μ†Œ(toggle zoom)

● μœˆλ„μš° ν•©μΉ˜κΈ°/뢄리 λ“±

(Ctrl+b + : 둜 λͺ…λ Ήμ°½ μ—΄κΈ°)

1
2
3
4
join-pane -s 2 -t 1   # 2번 μœˆλ„μš°λ₯Ό 1번 μœˆλ„μš°λ‘œ ν•©μΉ˜κΈ°
break-pane -s 1 -t 2  # 1번 μœˆλ„μš°λ₯Ό 2번 μœˆλ„μš°λ‘œ 뢄리
swap-pane -s 1 -t 2   # 두 νŒ¨λ„ κ΅ν™˜
swap-window -s 1 -t 2 # 두 μœˆλ„μš° κ΅ν™˜

5. νŒ¨λ„(Pane)

μœˆλ„μš° λ‚΄λΆ€λ₯Ό μ—¬λŸ¬ μ˜μ—­μœΌλ‘œ λ‚˜λˆ„μ–΄ μ‚¬μš©ν•  수 μžˆλ‹€.

● νŒ¨λ„ 뢄리(split)

단좕킀섀λͺ…
Ctrl+b + %μ„Έλ‘œ λΆ„ν•  (vertical)
Ctrl+b + "κ°€λ‘œ λΆ„ν•  (horizontal)

● νŒ¨λ„ 이동

단좕킀섀λͺ…
Ctrl+b + ← / β†’ / ↑ / ↓방ν–₯ν‚€λ‘œ 이동
Ctrl+b + oλ‹€μŒ νŒ¨λ„
Ctrl+b + ;이전 νŒ¨λ„
Ctrl+b + { / }νŒ¨λ„ μœ„μΉ˜ 이동
Ctrl+b + !νŒ¨λ„μ„ μƒˆ μœˆλ„μš°λ‘œ 뢄리
Ctrl+b + xνŒ¨λ„ μ’…λ£Œ
Ctrl+b + Ctrl+oνŒ¨λ„ μˆœν™˜(swap)

● νŒ¨λ„ 크기 쑰절

(Ctrl+b + : λͺ…λ Ήμ°½μ—μ„œ μ‹€ν–‰)

1
2
3
4
5
6
7
8
9
10
11
resize-pane -D
resize-pane -U
resize-pane -L
resize-pane -R

resize-pane -D 10  # 10μΉΈ λ³€κ²½
resize-pane -U 10
resize-pane -L 10
resize-pane -R 10

ctrl + b λ₯Ό λˆ„λ₯΄κ³  option + λ°©ν–₯ν‚€λ‘œ μ‚¬μ΄γ…ˆ 쑰절 (macOS)

6. 볡사/λΆ™μ—¬λ„£κΈ°(Copy Mode)

● μ§„μž…/μ’…λ£Œ

  • Ctrl+b + [ : 볡사λͺ¨λ“œ μ§„μž…
  • Ctrl+b + ] : λΆ™μ—¬λ„£κΈ°

● 볡사λͺ¨λ“œ 단좕킀

ν‚€μ„€λͺ…
Space선택 μ‹œμž‘
Enter선택 볡사
Esc선택 μ·¨μ†Œ
g / Gμœ„/μ•„λž˜ 끝 이동
h/j/k/lλ°©ν–₯ 이동
/검색
#paste buffer λͺ©λ‘
qμ’…λ£Œ

7. 슀크둀

  • ν‚€λ³΄λ“œλ‘œ: Ctrl+b + [ β†’ ↑/↓
  • 마우슀둜 μŠ€ν¬λ‘€ν•˜λ €λ©΄ .tmux.conf에 μΆ”κ°€:
1
set -g mouse on

8. Tmux Plugin Manager (TPM)

tmux ν”ŒλŸ¬κ·ΈμΈμ„ κ΄€λ¦¬ν•΄μ£ΌλŠ” 툴.

● μ„€μΉ˜

1
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

● .tmux.conf μ„€μ • μ˜ˆμ‹œ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# --- TPM ---
set -g @plugin 'tmux-plugins/tpm'

# plugin list
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'jimeh/tmux-themepack'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# themepack config
set -g @themepack 'powerline/default/cyan'

# resurrect
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-restore 'on'

# tmux settings
set -g default-terminal "screen-256color"
set -g mouse on

# initialize TPM
run '~/.tmux/plugins/tpm/tpm'

● ν”ŒλŸ¬κ·ΈμΈ μ„€μΉ˜

tmux λ‚΄μ—μ„œ:

1
2
3
4
Ctrl+b + :
source-file ~/.tmux.conf

Ctrl+b + I   # Plugin Install

9. Resurrect/Continuum 팁

μ„Έμ…˜μ„ killν–ˆλŠ”λ°λ„ λ‹€μ‹œ μ‚΄μ•„λ‚˜λŠ” κ²½μš°κ°€ μžˆλ‹€λ©΄ tmux-resurrect + tmux-continuum의 μžλ™ 볡원 κΈ°λŠ₯ λ•Œλ¬Έμ΄λ‹€. @continuum-restore 'on' μƒνƒœμ—μ„œλŠ” tmux μ‹œμž‘ μ‹œμ μ— λ§ˆμ§€λ§‰ μ €μž₯ μƒνƒœλ₯Ό μžλ™μœΌλ‘œ λ³΅μ›ν•œλ‹€.

● 볡원 데이터 μ €μž₯ μœ„μΉ˜

1
~/.local/share/tmux/resurrect/

● 볡원 데이터 μ‚­μ œ(μ΄ˆκΈ°ν™”)

1
2
tmux kill-server
rm -rf ~/.local/share/tmux/resurrect/*

● μžλ™ 볡원 끄기

1
set -g @continuum-restore 'off'
This post is licensed under CC BY 4.0 by the author.