tmux のキーバインドを vi 風にする

tmux の設定を弄って vi 風のキーバインドに変更します。 といっても、 rpm でインストールした tmux には設定ファイルのサンプルが入っていますんで、それをそのまま使わせてもらいます。


【前提】
OS: Scientific Linux 6.3

  • tmux を vi 風キーバインドにする(~/.tmux.conf)

  • 設定ファイルのサンプルがある場所はこちらです。
    # cd /usr/share/doc/tmux-1.5/examples
    # ls -l
    合計 36
    -rw-r--r-- 1 root root 2014  7月  9 18:24 2011 bash_completion_tmux.sh
    -rw-r--r-- 1 root root  913  7月  9 18:24 2011 h-boetes.conf
    -rw-r--r-- 1 root root 2338  7月  9 18:24 2011 n-marriott.conf
    -rw-r--r-- 1 root root 1799  7月  9 18:24 2011 screen-keys.conf
    -rw-r--r-- 1 root root 2789  7月  9 18:24 2011 t-williams.conf
    -rw-r--r-- 1 root root 5333  7月  9 18:24 2011 tmux.vim
    -rw-r--r-- 1 root root 2513  7月  9 18:24 2011 tmux_backup.sh
    -rw-r--r-- 1 root root 1088  7月  9 18:24 2011 vim-keys.conf
    

    [ ファイルの説明 ]
    • *.conf
    • tmux 設定ファイルのサンプルです。
    • tmux.vim
    • vim 用のシンタックスファイルです。
    • bash_completion_tmux.sh
    • bash のコマンドライン上で tmux のオプションが補完されるようにするための設定ファイルです。
      source bash_completion_tmux.sh として使います。
    • tmux_backup.sh
    • シェルを実行すると tmux 上の各端末(pane)の出力をファイルに吐き出します。

    tmux のキーバインドを vi 風にするには vim-keys.conf を使います。 vim-keys.conf を ~/.tmux.conf としてコピーして下さい。

    設定ファイルの中身を抜粋したものがこちら。
    # split windows like vim
    # vim's definition of a horizontal/vertical split is reversed from tmux's
    bind s split-window -v
    bind v split-window -h
    
    # move around panes with hjkl, as one would in vim after pressing ctrl-w
    bind h select-pane -L
    bind j select-pane -D
    bind k select-pane -U
    bind l select-pane -R
    
    # resize panes like vim
    # feel free to change the "1" to however many lines you want to resize by, only
    # one at a time can be slow
    bind < resize-pane -L 1
    bind > resize-pane -R 1
    bind - resize-pane -D 1
    bind + resize-pane -U 1
    
    # bind : to command-prompt like vim
    # this is the default in tmux already
    bind : command-prompt
    
    # vi-style controls for copy mode
    setw -g mode-keys vi
    

    こうすることで pane の水平分割が s キー(vi の :sp)、垂直分割が v キー(vi の :vsp)でできたり、 pane の移動が h,j,k,l キーでできるようになります。



【関連】

このブログの人気の投稿

zsh 設定 - プロンプト -

テンションを上げたいときにおすすめの曲(StarrySky YEAH! Remix)

OpenLDAP のログ周りの設定をする