Skip to content

Instantly share code, notes, and snippets.

@realmovestar
Last active October 17, 2023 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realmovestar/dd29dbfe8bd0dfbf9b89bee9df28c0a9 to your computer and use it in GitHub Desktop.
Save realmovestar/dd29dbfe8bd0dfbf9b89bee9df28c0a9 to your computer and use it in GitHub Desktop.
tmux setting
# 참고자료
# https://www.apress.com/kr/book/9781484207765
# https://leanpub.com/the-tao-of-tmux/read
# Prefix Command 변경.
unbind C-b
set -g prefix C-Space
set -g default-terminal "screen-256color"
# 창 맨 아래부분에 상태표시줄을 보여준다.
set -g status on
# 마우스 기능 활성화
set -g mouse on
# utf8 관련 옵션은 없어졌다.(기본이 utf8로 지정된듯함.)
#set-window-option -g utf8 on
#set -g status-utf8 on
# window buffer에서 vi motion 사용
set-window-option -g mode-keys vi
# command prompt에서 vi motion을 쓸 수 있도록 한다.
set-option -g status-keys vi
set -sg escape-time 0
# 자동으로 윈도우 이름이 변경되는 것을 방지.
set-option -g allow-rename off
# 윈도우 번호를 1부터 시작.(기본 0)
set -g base-index 1
# screen buffer (default 2000 lines)
set -g history-limit 100000
set-option -g renumber-windows on
# tmux error message를 보여주는 시간(기본 750ms)
set-option -g display-time 2000
# Prefix Command 없이 연속적으로 명령을 입력할 수 있는 시간.
set -g repeat-time 1000
setw -g pane-base-index 1
# pane에도 이름을 설정할 수 있다.
set -g pane-border-status top
set -g pane-border-format "#{pane_index} #{pane_current_command}"
# vi 스타일 pane 이동.
# -r옵션은 해당 명령을 연속적으로 입력할 수 있도록 한다.
# 반복적으로 prefix command를 안해도 된다.
# `<P>jjjj` 처럼 쓸 수 있도록 한다.
# 단 repeat-time 안에 입력해야한다.
bind-key -r h select-pane -L
bind-key -r j select-pane -D
bind-key -r k select-pane -U
bind-key -r l select-pane -R
# 방향키도 쓸 수 있도록 설정
bind-key -r Up select-pane -U
bind-key -r Down select-pane -D
bind-key -r Left select-pane -L
bind-key -r Right select-pane -R
# vi style split window (^Ws, ^Wv)
# 위, 아래로 나눈다.
bind-key s split-window -v
# 왼쪽, 오른쪽으로 나눈다.
bind-key v split-window -h
# 창 크기 조절
bind-key -r < resize-pane -L 1
bind-key -r > resize-pane -R 1
bind-key -r + resize-pane -U 1
bind-key -r - resize-pane -D 1
# copy-mode에서 vi처럼 동작하게(>=2.4)
bind P paste-buffer
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# paste 버퍼의 내용을 OS 클립보드로 복사(Alt + y)
#
# WSL
# https://github.com/Microsoft/WSL/issues/1586#issuecomment-472682842
if-shell '[ -e /mnt/c/Windows/System32/clip.exe ]' 'bind-key -n M-y run "tmux save-buffer - | /mnt/c/Windows/System32/clip.exe" \; display-message "Copyed buffer."'
# MacOS
if-shell '[ -e /usr/bin/pbcopy ]' 'bind-key -n M-y run "tmux save-buffer - | /user/bin/pbcopy" \; display-message "Copied buffer."'
# OS 클립보드를 버퍼로 복사
# PowerShell 옵션에서 Ctrl+Shift+C/V를 복사/붙여넣기로 사용 선택.
# }}}
# 창 정렬.
bind-key = select-layout even-vertical
bind-key | select-layout even-horizontal
# 설정 다시 읽기
bind-key r source ~/.tmux.conf
@realmovestar
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment