GNU screenからtmuxへの乗り換え

2011-03-21

GNU screenからtmuxへの乗り換え

screen派が続々とtmuxへ乗り換えているらしい・・・。 というわけで、tmuxをインストールして、設定。   ※設定内容は、なるべくscreenライクになるようにしてみた。   

1. インストール

1
2
3
4
5
6
#libevent-devel, ncurses-develはインストールしとく。
tar xvzf tmux-1.4
cd tmux-1.4
./configure
make
sudo make install

管理者権限が無い場合は、installだけ下記に /home/[user]/binにインストールされる。

1
make install PREFIX=$HOME

 

2. tmuxの設定

256色起動するため、aliasをセット。 vi ~/.bashrc

1
alias tmux="tmux -2"

  vi ~/.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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# prefixキーをctrl+tへ変更
set-option -g prefix C-t
unbind-key C-b
bind-key C-t send-prefix

# prefix + r で設定ファイルを再読み込み(私的には最重要設定)
bind r source-file ~/.tmux.conf

# prefixキー連打で直前のウィンドウと切り替え
unbind C-t
bind-key C-t last-window

# copyモードのキーバインドをvi風に
set-window-option -g mode-keys vi

# ステータスバーを白地にシックな青で大人っぽく。
set-option -g status-bg colour7
set-option -g status-fg black
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-bg colour12
set-window-option -g window-status-current-attr bold#,underscore

# 縦画面分割、横画面分割をviライクに割当
bind s split-window -v
bind v split-window -h

# 分割画面への移動をviライクに割当
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# prefix + spaceでウィンドウの一覧表示
bind Space choose-window

# ctrl + 左右矢印でウィンドウ切替
unbind-key C-Left
bind-key -n C-Left prev
unbind-key C-Right
bind-key -n C-Right next

これで、screenで使っていた時と同じ感覚でtmux使えるのでした。