#
# author : lsgx <lsgxthink@gmail.com>
# modified : 2014-11-12
#
#-- base settings --#
set -g default-terminal "screen-256color" # 設置終端缺省的支持顏色爲256色
set -g display-time 3000 # 提示信息的持續時間;設置足夠的時間以免看不清提示,單位爲毫秒
set -g escape-time 0 # 等待時間的持續時間;設置越小越好
set -g history-limit 65535 # 歷史記錄條數的最大限制值
#set -g base-index 1 # 窗口的初始序號;默認爲0,這裏設置爲1
#set -g pane-base-index 1 # 面板的初始序號;默認爲0,這裏設置爲1
#set -sg repeat-time 600 # 控制檯激活後的持續時間;設置合適的時間以免每次操做都要先激活控制檯,單位爲毫秒
#set -s quiet on
#setw -g xterm-keys on
#-- bindkeys --#
# prefix key (Ctrl+a) # 將激活控制檯的快捷鍵由Ctrl+b修改成Ctrl+a
set -g prefix ^a
unbind ^b
bind a send-prefix
# split window # 窗口分割
unbind '"'
bind - splitw -v # vertical split (prefix -) # 上下分割窗口
unbind %
bind | splitw -h # horizontal split (prefix |) # 左右分割窗口
# select pane # 選擇面板
bind k selectp -U # above (prefix k) # 選擇上面板
bind j selectp -D # below (prefix j) # 選擇下面板
bind h selectp -L # left (prefix h) # 選擇左面板
bind l selectp -R # right (prefix l) # 選擇右面板
# resize pane
bind -r ^k resizep -U 2 # upward (prefix Ctrl+k) # 當前面板上移2
bind -r ^j resizep -D 2 # downward (prefix Ctrl+j) # 當前面板下移2
bind -r ^h resizep -L 2 # to the left (prefix Ctrl+h) # 當前面板左移2
bind -r ^l resizep -R 2 # to the right (prefix Ctrl+l) # 當前面板右移2
# swap pane
bind ^u swapp -U # swap with the previous pane (prefix Ctrl+u) # 與上面板交換
bind ^d swapp -D # swap with the next pane (prefix Ctrl+d) # 與下面板交換
# create new session
bind C-c new-session # 建立一個新的會話
# control sessions
bind z kill-session # 結束一個會話
# find session
bind C-f command-prompt -p find-session 'switch-client -t %%' # 查找會話
# clear both screen and history
#bind -n C-l send-keys C-l \; run 'tmux clear-history' # 清空屏幕內容和歷史記錄
# reload config (prefix r)
bind r source ~/.tmux.conf \; display "Configuration reloaded!" # 從新加載配置文件
# misc
bind e lastp # select the last pane (prefix e) # 選擇最後一個面板
bind ^e last # select the last window (prefix Ctrl+e) # 選擇最後一個窗口
bind q killp # kill pane (prefix q) # 關閉當前面板
bind ^q killw # kill window (prefix Ctrl+q) # 關閉當前窗口
# app
bind ! splitw htop # htop (prefix !)
bind m command-prompt "splitw 'exec man %%'" # man (prefix m)
bind @ command-prompt "splitw 'exec perldoc -t -f %%'" # perl func (prefix @)
bind * command-prompt "splitw 'exec perldoc -t -v %%'" # perl var (prefix *)
bind % command-prompt "splitw 'exec perldoc -t %%'" # perl doc (prefix %)
bind / command-prompt "splitw 'exec ri %%'" # ruby doc (prefix /)
#-- statusbar --#
set -g status-utf8 on # 開啓狀態欄的UTF-8支持
set -g status-interval 1 # 狀態欄的分辨時間間隔
set -g status-keys vi # 操做狀態欄時的默認鍵盤佈局;能夠設置爲vi或emacs
set -g visual-activity on # 開啓窗口操做的可視
set -g set-clipboard on # 開啓剪切板
set -g display-panes-time 800 # slightly longer pane indicators display time # 稍長的窗格中顯示的時間指標
set -g display-time 1000 # slightly longer status messages display time # 稍長的狀態消息的顯示時間
set -g renumber-windows on # renumber windows when a window is closed # 關閉窗口後從新編號
setw -g automatic-rename on # rename window to reflect current program # 重命名窗口,以反映當前的程序
setw -g utf8 on # 開啓窗口的UTF-8支持
setw -g monitor-activity on # 開啓窗口活動監視
setw -g mode-keys vi # 複製模式中的默認鍵盤佈局;能夠設置爲vi或emacs
setw -g clock-mode-style 24 # 24 hour clock # 24小時顯示方式
#setw -g mode-mouse on # 開啓鼠標模式
# copy mode
bind Enter copy-mode # enter copy mode # 按Enter進入複製模式
bind b list-buffers # list paster buffers # 複製緩衝區列表
bind p paste-buffer # paste from the top pate buffer # 粘貼最後複製的緩衝區內容
bind P choose-buffer # choose which buffer to paste from # 選擇粘貼緩衝區
# the following vi-copy bindings match my vim settings
# see https://github.com/gpakosz/.vim.git
bind -t vi-copy v begin-selection # 複製模式下開始選取
bind -t vi-copy C-v rectangle-toggle # 複製模式下矩形選取
bind -t vi-copy y copy-selection # 複製模式下複製選取的內容
bind -t vi-copy Escape cancel # 複製模式下退出複製模式
bind -t vi-copy H start-of-line # 複製模式下開始行選取
bind -t vi-copy L end-of-line # 複製模式下結束行選取
# mouse resize selcet
#setw -g mouse-resize-pane on # 鼠標調整面板大小
#setw -g mouse-select-pane on # 鼠標選擇面板
#setw -g mouse-select-window on # 鼠標選擇窗口
# move x clipboard into tmux paste buffer
bind C-p run "tmux set-buffer \"$(xclip -o -sel clipbaord)\"; tmux paste-buffer"
# move tmux copy buffer into x clipboard
bind C-y run "tmux show-buffer | xclip -i -sel clipbaord"
#-- colorscheme --#
# see also: https://github.com/daethorian/conf-tmux/blob/master/colors/zenburn.conf
# modes
setw -g clock-mode-colour colour223
setw -g mode-attr bold
setw -g mode-fg colour223
setw -g mode-bg colour235
# panes
set -g pane-border-bg colour234
set -g pane-border-fg colour234
set -g pane-active-border-bg colour232
set -g pane-active-border-fg colour232
# statusbar
set -g status-justify centre
set -g status-bg colour235
set -g status-fg colour248
set -g status-attr dim
set -g status-left "#[fg=green,bright]Session: #S #[fg=yellow,bright]Window: #I #[fg=cyan,bright]Pane: #P"
set -g status-left-attr bright
set -g status-left-length 30
set -g status-right "#[fg=yellow,bright][ #[fg=cyan,bright]#W #[fg=yellow,bright]]#[default] #[fg=yellow,bright]- %Y.%m.%d #[fg=green,bright]%H:%M #[default]"
set -g status-right-attr bright
set-option -g status-right-length 30
setw -g window-status-current-fg colour223
setw -g window-status-current-bg colour237
setw -g window-status-current-attr bold
#setw -g window-status-current-format "#I:#W#F"
#setw -g window-status-alert-attr bold
#setw -g window-status-alert-fg colour255
#setw -g window-status-alert-bg colour160
# messages
set -g message-attr bold
set -g message-fg colour223
set -g message-bg colour235