LoginSignup
15
13

More than 5 years have passed since last update.

tmuxの個人的なオススメメモ

Last updated at Posted at 2015-10-07

設定内容 (v2.4向け)

# optional
set-option -g status-right '[%Y-%m-%d(%a) %H:%M]'

# keybind
unbind r
bind r source-file ~/.tmux.conf \; display-message "reload config!!"
set -g history-limit 10000

unbind %
bind | split-window -h
unbind '"'
bind - split-window -v

setw -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"

setw -g mode-keys vi

unbind v
unbind y
unbind enter
set -g default-command "reattach-to-user-namespace -l $SHELL"
unbind -T copy-mode-vi Enter
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind -T copy-mode-vi enter send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"

bind-key p paste-buffer

ちょっとした解説とやりたいこと

個人的なオススメなので、賛否両論あるかと思いますが、
初心者ゆえ良い設定があれば知りたい所存です。

右クリックできないのが辛いです。
状況はtmuxでコピーした内容がブラウザに貼り付けられないといった感じで、良い方法はないかなぁという気持ちです。
調べてみたもののみんなそんなに気にしてないのが不思議・・・。

brew install reattach-to-user-namespace

2015.10.23 追記

2.0まで有効だったmode-mouseがmouseに統合されました。

# 2.0まで
setw -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
# 2.1から
setw -g mouse on
bind -n WheelUpPane copy-mode

ホイールが効かないなぁと思って調べたら、WheelUpPaneというものが追加されているので、copy-modeにしてあげれば良いとのこと。

右クリックが相変わらずどうしたらいいかわからない……。

2015.11.10 追記

El Capitanにバージョンアップした際に、下記の機能が加わったようです。

thisischeckoff.png

チェックを外すとmode-mouseが使えました。
ナンテコッタ。

2015.11.10 追記

代替screenをオフにしていたけど、諸々挙動がおかしいのでオンにしました。

元の状態にするにはどうすればいいんだ!ってことで調べたところ、下記の通りにすれば大丈夫でした。

$ tmux -V
tmux 2.2

$ vim ~/.tmux.conf
unbind r
bind r source-file ~/.tmux.conf \; display-message "reload config!!"
set -g history-limit 10000

unbind %
bind | split-window -h
unbind '"'
bind - split-window -v

setw -g mouse on
bind -n WheelUpPane copy-mode

#setw -g mode-mouse on
#set -g mouse-resize-pane on
#set -g mouse-select-pane on
#set -g mouse-select-window on
set-option -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"

setw -g mode-keys vi
set-option -g default-command "reattach-to-user-namespace -l zsh"

unbind ]
bind-key p paste-buffer
bind-key -t vi-copy v begin-selection

unbind Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
unbind y
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

2016.6.12 追記

zshを標準利用する場合、set-option -g default-command "reattach-to-user-namespace -l zsh"はない方が良いとのことで、削除しました。

$ tmux -V
tmux 2.2

$ vim ~/.tmux.conf
unbind r
bind r source-file ~/.tmux.conf \; display-message "reload config!!"
set -g history-limit 10000

unbind %
bind | split-window -h
unbind '"'
bind - split-window -v

setw -g mouse on
bind -n WheelUpPane copy-mode

#setw -g mode-mouse on
#set -g mouse-resize-pane on
#set -g mouse-select-pane on
#set -g mouse-select-window on
set-option -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"

setw -g mode-keys vi

unbind ]
bind-key p paste-buffer
bind-key -t vi-copy v begin-selection

unbind Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
unbind y
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

2017.02.15 追記

そうか…この記事書いて1年近く経つのか、と思ってた、いろいろ眺めてたらzplugの作者さんがこんな記事を書いていましたので、ご紹介まで。

一部設定を反映させていただきました。
内容は以下の通りです。

$ tmux -V
tmux 2.3

$ vim ~/.tmux.config
# optional
set-option -g status-right '[%Y-%m-%d(%a) %H:%M]'

# keybind
unbind r
bind r source-file ~/.tmux.conf \; display-message "reload config!!"
set -g history-limit 10000

unbind %
bind | split-window -h
unbind '"'
bind - split-window -v

setw -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"

setw -g mode-keys vi

unbind ]
bind-key p paste-buffer
bind-key -t vi-copy v begin-selection

unbind Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
unbind y
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

2017.04.28 追記(v2.3版)

unbind r
bind r source-file ~/.tmux.conf \; display-message "reload config!!"
set -g history-limit 10000

unbind %
bind | split-window -h
unbind '"'
bind - split-window -v

setw -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on

setw -g mode-keys vi
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

unbind ]
bind-key p paste-buffer
15
13
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
15
13