Skip to content

Instantly share code, notes, and snippets.

@tkomaki
Last active May 6, 2020 02:57
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 tkomaki/26c63a975f8fe99dab96e266653f8ec2 to your computer and use it in GitHub Desktop.
Save tkomaki/26c63a975f8fe99dab96e266653f8ec2 to your computer and use it in GitHub Desktop.
#######################
## 基本設定& 外観設定など ##
#######################
## ヒストリーの限界値
set-option -g history-limit 20000
## ステータスバーの表示とか色を変更
set-option -g status-right "#[fg=black][%Y/%m/%d %H:%M]"
set-option -g status-left '#H:[#P]'
set-option -g status-bg cyan
## アクティブなpaneの色を変更
set -g pane-active-border-style fg=colour31
#set -g pane-active-border-style bg=colour31
#メッセージ表示時間指定(default 1000msを15秒に変更)
set-option -g display-time 15000
set-option -g display-panes-time 15000
## prefix + eを押したら全パネルsync(全パネルで同じコマンドを同時に入力)
bind e setw synchronize-panes \; display "synchronize-panes #{?pane_synchronized,on,off}"
## コピーモードをスペースキーで開始とかにする(全体的にvi風にする)
set-window-option -g mode-keys vi
setw -g mode-keys vi
##################
## キーバインド関連 ##
##################
## prefix + - で水平分割
bind = split-window -v
## prefix + | で垂直分割
bind | split-window -h
## prefix + / で前方検索(逆サーチ)できるように設定
bind-key / copy-mode \; send-key ?
## 矩形選択を ctrl+v に設定
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
## sessionの移動をShift + down/up で行う(Shift + 上下矢印キー)
bind -n S-down switch-client -n
bind -n S-up switch-client -p
## paneの移動(rotate)Shift + left/right で行う(Shift + 左右矢印キー)
## 普通の移動を割り当てると左右のキーだけでは上のpaneとかに移動できないのでrotateを使用する
bind -n S-left select-pane -t :.-
bind -n S-right select-pane -t :.+
# prefix + hでログ取得を開始してHで終了(事前に ~/.tmux ディレクトリは作成しておくこと)
bind-key h pipe-pane -o '/bin/sh -c "while read -r TMUXLINE; do echo \"\${TMUXLINE}\" >> \${HOME}/.tmux/\$(date +%Y%m%d-%H%M%S)-#S-#I.#P.log; done "' \; display-message "Logging start to ~/.tmux"
bind-key H pipe-pane \; display-message 'Stop logging to ~/.tmux'
############################
## マウス/トラックパッド周りの設定 ##
############################
## マウスでスクロールできるようにする
# for iterm2 Preference -> Profiles -> Terminal [Enable xterm mouse reporting]
# [Save lines to scrollback when an app status bar is present]
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set-option -g mouse on
## マウスでコピーができるようにする
###for linux#####
#bind -n WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
#bind -n WheelDownPane select-pane -t= \; send-keys -M
#############
###for Mac OS##########
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 WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
bind -n WheelDownPane select-pane -t= \; send-keys -M
bind -T copy-mode-vi C-WheelUpPane send-keys -X halfpage-up
bind -T copy-mode-vi C-WheelDownPane send-keys -X halfpage-down
#######################
## PC側とクリップボード共有
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment