Skip to content

Instantly share code, notes, and snippets.

@sousk
Last active May 3, 2017 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sousk/5c0b2f6b8cea3b74f1bc4ff9a8eb0a04 to your computer and use it in GitHub Desktop.
Save sousk/5c0b2f6b8cea3b74f1bc4ff9a8eb0a04 to your computer and use it in GitHub Desktop.
tmux.conf
set-option -g mouse on
# ** Wheel scroll in pane
unbind -T root WheelUpPane
unbind -T root WheelDownPane
# Do mouse wheel-up to enter copy mode and do page-up
# https://groups.google.com/d/msg/tmux-users/XTrSVUR15Zk/3iyJLMyQ7PwJ
# Below binding did not work
# bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'if -Ft= "#{pane_in_mode}" "copy-mode -u" "send-keys -M"' 'copy-mode -u'
# Below works and allows the WheelUpPane binding in emacs-copy table to be effective
bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= "#{pane_in_mode}" "send-keys -M" "copy-mode -u"'
# |---------------------+-----------------------------------------+--------------------------------|
# | using mouse? AND .. | #{pane_in_mode} (already in copy-mode?) | action |
# |---------------------+-----------------------------------------+--------------------------------|
# | Yes | Don't care | Send the mode keys |
# | No | Yes | Send the mode keys |
# | No | No | Enable copy-mode and do PageUp |
# |---------------------+-----------------------------------------+--------------------------------|
#
# *** Wheel scroll in pane WHILE in copy-mode
# Once in copy-mode, mouse wheel scrolls scrolls by half pages
bind -Tcopy-mode send -X WheelUpPane halfpage-up
bind -Tcopy-mode send -X WheelDownPane halfpage-down
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
# ステータスバーをトップに配置する
set-option -g status-position top
# 左右のステータスバーの長さを決定する
set-option -g status-left-length 90
set-option -g status-right-length 90
# #H => マシン名
# #P => ペイン番号
# 最左に表示
set-option -g status-left '#H:[#P]'
# Wi-Fi、バッテリー残量、現在時刻
# 最右に表示
set-option -g status-right '#(get_ssid) #(battery -c tmux) [%Y-%m-%d(%a) %H:%M]'
# ステータスバーを Utf-8 に対応
set-option -g status-utf8 on
# ステータスバーを1秒毎に描画し直す
set-option -g status-interval 1
# センタライズ(主にウィンドウ番号など)
set-option -g status-justify centre
#### COLOUR (Solarized 256)
# default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg colour244 #base0
set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim
# active window title colors
set-window-option -g window-status-current-fg colour166 #orange
set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright
# pane border
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01
# message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange
# pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange
# clock
set-window-option -g clock-mode-colour colour64 #green
# bell
set-window-option -g window-status-bell-style fg=colour235,bg=colour160 #base02, red
# Vi キーバインド
set-window-option -g mode-keys vi
# Prefix+v でコピーモード開始
bind-key v copy-mode \; display "Copy mode!"
bind-key -Tcopy-mode v send -X begin-selection
# Prefix+Enter/y でコピー
bind-key -Tcopy-mode Enter send -X copy-pipe "reattach-to-user-namespace pbcopy"
bind-key -Tcopy-mode y send -X copy-pipe "reattach-to-user-namespace pbcopy"
# Prefix+p でペースト
# クリップボードにも保存されているので Cmd-v でもペースト可能
bind-key p paste-buffer
# Esc キーでコピーの反転を解除(コピーモードは抜けない)
bind-key -Tcopy-mode Escape send -X clear-selection
# Ctrl-c キーでコピーの反転を解除し、コピーモードから抜ける
bind-key -Tcopy-mode C-c send -X cancel
# コピーモード中(Prefix+v 後)C-v で矩形選択開始
bind-key -Tcopy-mode C-v  send -X  rectangle-toggle
# 1行選択
bind-key -Tcopy-mode V  send -X   select-line
# Vi モード中に Ctrl-a で行頭に(Emacs ライク)
bind-key -Tcopy-mode C-a  send -X  start-of-line
# Vi モード中に Ctrl-e で行末に(Emacs ライク)
bind-key -Tcopy-mode C-e  send -X  end-of-line
# 単語の最初の1文字に移動
bind-key -Tcopy-mode w   send -X  next-word
# 単語の最後の1文字に移動
bind-key -Tcopy-mode e  send -X   next-word-end
# w の逆の動き back
bind-key -Tcopy-mode b  send -X   previous-word
# 画面上に映る最上行に移動
bind-key -Tcopy-mode g   send -X  top-line
# 画面上に映る最下行に移動
bind-key -Tcopy-mode G  send -X   bottom-line
# 前方検索
bind-key -Tcopy-mode /   send -X  search-forward
# 後方検索
bind-key -Tcopy-mode ?  send -X   search-backward
# ページスクロール
bind-key -Tcopy-mode C-n  send -X page-up
bind-key -Tcopy-mode C-f  send -X  page-down
# ページ送り
bind-key -Tcopy-mode C-u  send -X  scroll-up
bind-key -Tcopy-mode C-d   send -X scroll-down
# ウィンドウとペインの番号を1から開始する(デフォルト0)
set-option -g base-index 1
set-window-option -g pane-base-index 1
# Prefix+- で横に、Prefix+| で縦に分割(ペイン)する
bind-key | split-window -h
bind-key - split-window -v
# Prefix + Ctrl-h/l でウィンドウ切り替え
# Prefix + Ctrl-h,h,h,h,...と連打できる
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# Prefix+hjkl でペイン移動
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# ペインサイズを上下左右(Prefix+JKHL)に変更
# Prefix+J,J,J,J,...と連打してリサイズ可能
bind-key -r H resize-pane -L 5
bind-key -r J resize-pane -D 5
bind-key -r K resize-pane -U 5
bind-key -r L resize-pane -R 5
# Ctrl-o でペインをローテーションしながら移動
# Prefix を用いないのでタイプが楽だが、Ctrl-o を使用してしまう
# 他のソフトウェアの設定に支障をきたさないように注意
bind-key -n C-o select-pane -t :.+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment