tmuxのインストールと設定


tmuxのインストールと設定手順

rpmforgeレポジトリを追加

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
vim /etc/yum.repos.d/rpmforge.repo
# enabled=0にする

tmuxのインストール

yum install --enablerepo=rpmforge tmux

設定ファイル作成

cat > ~/.tmux.conf <<EOS
# utf-8環境
setw -g utf8 on
set -g status-utf8 on

#全てのベルを無視
set-option -g bell-action none
# ウィンドウ番号基準値
set-option -g base-index 1
# ウィンドウの自動リネームoff
set-window-option -g automatic-rename off
#ウィンドウで動作があるとステータスラインでハイライト
set-window-option -g monitor-activity on

# コピー、選択モードのキーバインドvi
set -g mode-keys vi

# プレフィックスキー C-t
unbind C-b
set-option -g prefix C-t

# 設定ファイル再読み込み r
bind r source-file ~/.tmux.conf

# 直前のウィンドウ t
bind C-t last-window

# デタッチ d
bind d detach

# タイトル変更 A
bind A command-prompt "rename-window %%"

# ウィンドウ選択画面
bind Space choose-window

# 新ウィンドウ作成
bind c new-window

# 分割していたペインそれぞれをWindowに
bind b break-pane

# ペイン終了
bind k kill-pane
# ウィンドウ終了
bind K kill-window

# ペイン番号表示
bind i display-panes

# ペインの縦分割
bind H split-window -v
# ペインの横分割
bind v split-window -h

# ペインの移動
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# 文字色と背景色
set -g status-fg black
set -g status-bg white

# 現在のウィンドウの色
set-window-option -g window-status-current-fg   white
set-window-option -g window-status-current-bg   blue

# rbenv localを使えるようにする
set-environment -gu RBENV_VERSION

EOS

よく使うコマンド

# セッション作成
tmux new -s {session-name}
# アタッチ
tmux a(attach)
# デタッチ
tmux detach -s {target-session}
# セッション一覧
tmux ls(list-session)
# クライアント一覧
tmux lsc(list-client)
# キーバインド一覧 
tmux list-keys

# コピーモード
コピーモード開始 C-t [
コピー始点選択 Space
コピー終点選択 Enter
貼り付け C-t ]