본문 바로가기
C.W.K.
Stream
Lesson 01 of 03 · published

필수 .tmux.conf 설정

~14 min · tmux, config, keybindings

Level 0갇힌 자
0 XP0/35 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

Config가 사는 곳

tmux는 시작할 때 ~/.tmux.conf를 읽어. 고친 뒤에 재시작 없이 반영하려면 셸에서 tmux source-file ~/.tmux.conf를 돌리거나, 아래에서 걸어둘 키를 쓰면 돼.

첫 번째로 할 일: prefix 바꾸기

Ctrl-b는 홈 row에서 손가락 두 개가 건너뛰어야 하는 자리야. Ctrl-a는 왼쪽 새끼손가락 바로 옆이고. 그래서 손에 익은 사람 대부분이 이걸 바꿔 써. 함정이 하나 있어. Ctrl-a는 bash나 readline에서 줄 맨 앞으로 가는 단축키이기도 하거든. 그러니 진짜로 줄 맨 앞으로 가고 싶을 땐 Ctrl-a a를 눌러야 해. 그래도 바꿀 값은 해.

Escape-time 고치기 — Vim에겐 결정적

기본 상태의 tmux는 Esc 뒤에 escape 시퀀스가 시작되는지 (옛 터미널의 화살표 키 같은 것) 보려고 잠깐 기다려. Vim을 쓴다면 이 지연이 끔찍해. Esc를 누를 때마다 끈적하게 걸리거든. set -sg escape-time 0이 그걸 없애줘. Vim 쓰는 사람에게 가장 중요한 tmux 설정 한 줄이야.

삶의 질 묶음

set -g base-index 1이랑 setw -g pane-base-index 1은 window와 pane 번호를 1부터 시작하게 해 (키보드 숫자 줄이랑 맞아떨어져). set -g renumber-windows on은 하나가 죽었을 때 번호를 다시 매겨서 1, 3, 7처럼 띄엄띄엄 남지 않게 해줘. set -g history-limit 50000은 스크롤백을 기본 2000줄에서 크게 늘려. set -g mouse on이면 클릭으로 옮겨 다니고 휠로 스크롤할 수 있고. setw -g mode-keys vi는 copy mode를 vi 방식으로 바꿔. set -g focus-events on은 pane을 옮길 때 Vim의 autoread가 제대로 동작하게 해줘.

True-color와 tmux 3.6에서 좋아진 것들

set -g default-terminal "tmux-256color"set -ag terminal-overrides ",xterm-256color:RGB"를 같이 걸면 24비트 색이 켜져서 Vim의 색 테마가 tmux 안에서도 제 색으로 보여. 2026년 기준 최신인 tmux 3.6에는 pane 스크롤바도 들어왔어. set -g pane-scrollbars on으로 켜.

더 나은 split 키 — 그리고 작업 디렉토리 물려주기

|-를 split 명령에 걸어둬. 거기에 -c "#{pane_current_path}"를 붙이면 새 pane이 지금 pane의 작업 디렉토리에서 열려. 켜자마자 체감되는 큰 개선이야.

Vim 방식 pane 이동

prefix + h/j/k/lselect-pane -L/-D/-U/-R에 걸어두면 Vim에서 split을 오가듯이 pane을 오갈 수 있어. 트랙 7에서는 prefix를 누를 필요조차 없애주는 vim-tmux-navigator를 다룰 거야.

config는 하나, 모든 줄은 의도적으로. 트랙 4에서 한 얘기랑 같아. 인터넷에서 500줄짜리 config를 통째로 집어오지 마. 아래 스물다섯 줄로 시작해서, 한 줄씩 이해하고, 불편한 데가 생기면 그때 더해. tmux는 작은 도구야. config도 작아도 돼.

Code

.tmux.conf reload·bash
# 편집 후 셸에서
tmux source-file ~/.tmux.conf

# 또는 tmux 안에서
prefix + :
source-file ~/.tmux.conf
Starter ~/.tmux.conf — 이 블록 통째로 붙여·tmux
# ───────────── Prefix ─────────────
unbind C-b
set -g prefix C-a
bind C-a send-prefix     # Ctrl-a 두 번 = 리터럴 Ctrl-a

# ───────────── Reload 바인딩 ─────────────
bind r source-file ~/.tmux.conf \; display "Config reloaded"

# ───────────── 인덱싱 ─────────────
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on

# ───────────── 동작 ─────────────
set -sg escape-time 0          # Vim 사용자에 결정적
set -g history-limit 50000
set -g mouse on
setw -g mode-keys vi           # copy mode 의 vi 키
set -g focus-events on         # Vim autoread 발동

# ───────────── 컬러 ─────────────
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"

# ───────────── Split — | 과 - 가 cwd 유지 ─────────────
unbind '"'
unbind %
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"

# ───────────── Vim 스타일 pane navigation ─────────────
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# 반복 가능 리사이즈
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
Copy-mode 키바인딩 — Vim 같은 시작/끝 선택·tmux
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi V send-keys -X select-line
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel

External links

Exercise

~/.tmux.conf를 만들거나 열어서 위 starter config를 붙여넣어. 셸에서 tmux kill-server로 돌고 있는 세션을 전부 정리한 다음 tmux new -s test를 실행해. 확인할 것들이야. (1) Ctrl-a가 새 prefix로 먹히는지, (2) prefix + |가 pane을 좌우로 가르고 새 pane이 같은 디렉토리에서 열리는지, (3) prefix + h/j/k/l로 pane을 오갈 수 있는지, (4) prefix + r가 config를 다시 읽고 "Config reloaded"를 띄우는지.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.