LoginSignup
5
6

More than 5 years have passed since last update.

tmux

Last updated at Posted at 2016-06-12

tmuxの設定

ホームディレクトリに「.tmux.comf」がなければ作成。

.tmux.conf
#キーバインドをvi風に
set-window-option -g mode-keys vi


# 5000行さかのぼれるように変更
set-option -g history-limit 5000

set-option -g mouse on

# 'v' で範囲選択開始 'y'でコピー(クリップボード)
# 'Enter'で範囲選択解除 + コピー(クリップボート)
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "iconv -s -t SJIS | putclip"; \
unbind -t vi-copy Enter
bind-key -t vi-copy enter copy-pipe "iconv -s -t SJIS | putclip"; \

# 1行コピー
bind-key -t vi-copy Y copy-line

# 異なるサイズの端末からアクセスした時にリサイズ
setw -g aggressive-resize on

#マウススクロール反映
set-window-option -g mouse on

#Prefix q ⇒ Pane に番号を表示。”3” キーを押すと移動。数字キーの入力有効な時間を 5 秒に延長。
set-option -g display-panes-time 5000

# | でペインを縦分割する
bind | split-window -h

# | でペインを縦分割する
bind - split-window -v

コピーモード

デフォルトのコピーモードのコマンド

コマンド 動作
Ctrl-b + [ copy モード開始
Space copy 開始位置決定
Enter copy 終了位置決定
Ctrl-b + > Clipboard への書き出し
Ctrl-b + ] copy モード終了

tmuxのコピーモードからクリップモードにコピーしたかったがはまったのでメモ!
クリップボードへのコピーコマンドはOSによって異なる

$OS コマンド
Linux xsel,xclip
Mac pbcopy
Cygwin putclip

なのでOSごとのクリップボードへのコピーの仕方は以下になる。

.tmux.conf
### for Linux
  bind-key -t vi-copy y copy-pipe "xsel -ib"; \
  bind-key -t vi-copy enter copy-pipe "xsel -ib"; \

### for Mac (持っていないので未確認)
  bind-key -t vi-copy y copy-pipe "pbcopy"; \
  bind-key -t vi-copy enter copy-pipe "pbcopy"; \

### for Cygwin
  bind-key -t vi-copy y copy-pipe "iconv -s -t SJIS | putclip"; \
  bind-key -t vi-copy enter copy-pipe "iconv -s -t SJIS | putclip"; \

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6