Tmux/ko

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Tmux and the translation is 59% complete.
Outdated translations are marked like this.
Resources

tmux (terminal multiplexer) 은 각기 다른 프로그램을 실행하는 여러 터미널(또는 창)을 단일 화면 또는 터미널 창으로 띄우고, 접근하고, 관리하는 프로그램입니다. tmux는 화면을 분리해도 백그라운드에서 여전히 동작하며, 나중에 다시 붙을 수 있습니다.[1] GNU Screen에 익숙한 사용자는 tmux가 좋은 대안이 될 수 있음을 확인하실 수 있습니다.

Users familiar with GNU Screen may find tmux as a suitable alternative.

설치

USE 플래그

USE flags for app-misc/tmux Terminal multiplexer

debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
utempter Include libutempter support
vim-syntax Pulls in related vim syntax scripts

Emerge

app-misc/tmux 을 설치하십시오:

root #emerge --ask tmux

설정

tmux의 표준 설치 방식으로는 전역 설정(/etc/tmux.conf) 파일 또는 사용자 설정(~/.tmux.conf)파일을 설치하지 않습니다. /usr/share/doc/tmux-2.0/examples 디렉터리에 예제 파일을 제공하며, 전역 또는 사용자 위치로 복사하여 원하는텍스트 편집기en로 편집할 수 있습니다.

Configuration Files

  • /etc/tmux.conf — the system-wide configuration file.
  • $XDG_CONFIG_HOME/.config/tmux/tmux.conf — The user specific tmux configuration file.
  • ~/.tmux.conf — The legacy single-user tmux configuration file location.


위키 예제

파일 ~/.tmux.conf
set -g default-terminal "screen-256color"   # Use 256 colors
set -g status-utf8 on                       # Enable utf-8
set -g history-limit 100000                 # Scrollback buffer number of lines
 
# Start window indexing at one instead of zero
set -g base-index 1
 
# Set the prefix key and some key bindings to match GNU Screen
set -g prefix C-a
bind-key C-a last-window
 
# Key bindings for horizontal and vertical panes
unbind %
bind | split-window -h
bind - split-window -v
 
# Enable window titles
#set -g set-titles on
 
# Window title string (uses statusbar variables)
set -g set-titles-string '#T'
 
# Status bar with load and time
set -g status-bg '#4e4e4e'
set -g status-fg '#ffffff'
set -g status-left ' '
set -g status-right '#[bg=#bbbbbb]#[fg=#000000]#(cut -d " " -f -3 /proc/loadavg) #[bg=#4e4e4e]#[fg=#ffffff]#(
date +" %H:%M ")'
set -g window-status-format '#I #W'
set -g window-status-current-format ' #I #W '
setw -g window-status-current-bg '#55ff55'
setw -g window-status-current-fg '#000000'
 
# Pane border colors
set -g pane-active-border-fg '#bbbbbb'
set -g pane-border-fg '#555555'
 
# Bind to reload config
bind r source-file ~/.tmux.conf
  1. Match session numbers to number row

set -g base-index 1

  1. Set TERM, the default is "screen", "screen-256color" can be tried if "tmux-256color" doesn't work.

set -g default-terminal "tmux-256color"

  1. Set prefix to 'a' with ctl-a > a to send ctrl-a to the terminal
  2. set -g prefix C-a
  3. bind-key a send-prefix
  4. Set prefix2 to the default 'b'
  5. set -g prefix2 C-b
  6. Enable mouse

set -g mouse on

  1. Disable drag action in normal mode if your pointer causes problems with

unbind -n MouseDrag1Pane

  1. Also disable in copy mode
  2. unbind -Tcopy-mode MouseDrag1Pane
  1. Set the bar and inactive borders to blue, highlighting current in green.
  2. set-option -g status-style fg=black,bg=blue
  3. set-window-option -g window-status-current-style bg=green
  4. set-option -g pane-border-style fg=blue
  5. set-option -g pane-active-border-style fg=green

}}

To reload the configuration file from a terminal run:

user $tmux source-file ~/.tmux.conf

Alternatively, modifications to the file can be loaded from within tmux via:

:source-file ~/.tmux.conf

Automatic connection

Running tmux with exec and the -ADX options will cause tmux to replace the current shell and create a session, or if one exists connect to it and both detach and exit the other client. This provides a very consistent way of working with remote sessions, and it can be run automatically:

Bash

user $test -n "$PS1" && test -z "$TMUX" -a -n "$SSH_TTY" && exec tmux new -ADX

Fish

user $status is-interactive ; and test -z "$TMUX" -a -n "$SSH_TTY" ; and exec tmux new -ADX

플러그인

tmux에 몇가지 추가 기능 이 있습니다. 사용할 수 있는 옵션은 하단 장을 참고하십시오.

tpm

tpm is a tmux plugin manager. See the tpm sub-article for more details on the installation process.

tmux-mem-cpu-load

tmux-mem-cpu-loadtmux 의 상태 표시줄에 시스템 동작 상태를 나타내도록 설계한 작은 프로그램입니다. 자세한 설치 방법은 tmux-mem-cpu-load 하위 글을 참고하십시오.

Tmux Resurrect

tmux-resurrect는 시스템을 다시 시작하는 동안에도 tmux 환경을 유지합니다. 설치 과정에 대한 자세한 내용은 Tmux Resurrect 하위 게시글en [2]을 살펴보십시오.

사용법

단축키

tmux는 prefix key stroke (기본 단축키는 Ctrl+b)와 명령키의 단축키 조합으로 현재 붙어있는 클라이언트를 관리할 수 있습니다.

Ctrl+B를 누르고 나서 다음 단축키를 사용할 수 있습니다.

일반

  • ? = 모든 단축키 조회
  • d = 현재 클라이언트 분리
  • : = tmux 명령 프롬프트 진입

창 만들기 및 관리

  • c = 새 창 만들기
  • n = 다음 창으로 이동
  • p = 이전 창으로 이동
  • l = 이전에 선택한 창으로 이동
  • 0-9 = 0번 부터 9번 까지의 창 중 하나를 선택
  • ' = 선택할 창 인덱스를 물어봅니다. 프롬프트가 뜬 후 숫자를 입력하면 해당 창으로 전환합니다.
  • , = 현재 창 이름 바꾸기
  • w = 대화방식으로 현재 창 선택.
  • :, 다음 list-windows enter = 창 목록 조회

하위 창 만들기 및 관리

  • " = 현재 하위 창을 수평으로 쪼갭니다
  • % = 현재 하위 창을 수직으로 쪼갭니다
  • o = 현재 창에서 다음 하위 창을 선택합니다
  • ; = 이전 활성화 상태의 하위 창으로 이동합니다
  • { = 현재 활성화 하위창과 이전 활성화 하위 창을 서로 바꿉니다.
  • } = 현재 하위 창과 다음 하위 창을 서로 바꿉니다
  • Ctrl+o = 현재 창의 하위창을 정방향으로 회전합니다.
  • Alt+1 to Alt+5 = 다섯가지 방식의 배치로 하위 창을 정렬합니다: even-horizontal, even-vertical, main-horizontal, main-vertical, tiled.
  • x = 현재 하위 창을 닫습니다.
  • ! = 창 밖에 있는 현재 하위 창의 동작을 중단합니다.

복사, 붙여넣기, 스크롤 동작

emacs 모드 (기본) 또는 vi 모드 둘 중 어느 하나를 선택하느냐에 따라 단축키가 달라집니다. mode-keys 옵션은 .tmux.conf에서 vi 모드로 설정할 수 있습니다.
  • [ = 텍스트를 복사하거나 기록 보기 모드로 진입합니다
  • ] = 최근에 복사한 버퍼 단위 텍스트를 붙여넣습니다
  • # = 붙일 버퍼의 모든 내용을 조회합니다
  • - = 버퍼에 복사한 최근의 대부분의 텍스트를 삭제합니다

세션 관리

세션 시작

tmux를 시작하면 /tmp/S-<UID>/<Session Name>에 세션별 소켓을 만듭니다

tmux는 다음 명령으로 시작할 수 있습니다:

user $tmux

또는 시작할 때 세션 이름을 부여하려면 다음을 실행하십시오:

user $tmux new-session -s portage

세션 조회

존재하는 세션의 정보를 보려 tmux의 세션을 조회해보겠습니다:

user $tmux ls
0: 1 windows (created Thu Apr  9 09:09:03 2015) [180x65] (attached)

세션을 조회할 때 세션의 이름은 세션 정보 줄 처음에 나타나야합니다. 이름 없이 만든 세셔는 상단에 언급한 출력을 통해 확인할 수 있으므로 세션은 0번과 같은 식으로 참조합니다.

세션을 조회하는 또 다른 방법은 긴 list-sessions 인자를 입력하는 방법입니다.

user $tmux list-sessions
0: 1 windows (created Thu Apr  9 09:09:03 2015) [180x65] (attached)

이전 목록 조회 명령과 정확하게 동일한 출력 내용으로 내용을 출력합니다.

세션 이름 바꾸기

tmux에서 세션을 그냥 시작하는 것만으로는 사람이 알아보기 쉬운 이름을 붙여놓지 않습니다.

기본 세션 이름이 충분히 이해하기 어렵다면(0은 충분한 설명을 의도하지 않음), 세션 이름을 바꿀 수 있습니다. Larry 소가 tmux를 시작할 때 세션 이름을 따로 지정하지 않았다고 가정해보겠습니다. 포티지 새 버전 컴파일을 시작하고 현재 작업 중인 상황을 반영하려 세션 이름을 바꾸려합니다. 세션 이름을 바꾸려면 우선 Ctrl+b 키를 누르고  : 키를 눌러 tmux 관리자를 띄워 tmux 관리 표시줄에 포커스가 뜨도록 합니다. 기본적으로 표시줄은 노란색으로 뜹니다. 표시줄이 뜨면 다음 명령을 실행하겠죠:

:rename-session -t 0 portage

0는 존재하는 (기본) 세션 이름이고 portage는 새 세션에 부여하려는 이름입니다. 떼어놓은 tmux 세션의 이름을 바꾸려면 다음 명령을 실행하십시오:

user $tmux rename-session -t 0 portage

세션 재개

세션을 떼어내고 나면 모든 활성 터미널은 활성화 상태로 남아있어 아직 끝나지 않은 명령은 그대로 수행합니다. 세션 작업을 재개하려면 attach -t <session_name> 옵션을 사용하십시오.

user $tmux a -t portage

또는 기존 세션에 붙는 긴 명령 방식을 사용하십시오:

user $tmux attach -t portage

데몬 유사 동작

세션에 붙지 않고 tmux 세션에서 (데몬처럼) 명령 실행을 시작하려면 new-session -d 옵션을 사용하고 따옴표에 실행할 명령을 뒤에 붙이십시오:

user $tmux new-session -d 'emerge -uDNvp @world'

추가 참조

외부 자료

Tutorial Videos

참고 자료