.vvconfig/.config/tmux/tmux.conf

138 lines
5.6 KiB
Plaintext

# Easy config reload
bind-key r source-file ~/.config/tmux/tmux.conf \; display-message "tmux.conf reloaded"
# Plugins
setenv -g TMUX_PLUGIN_MANAGER_PATH '~/.tmux/plugins'
set -g @plugin 'seebi/tmux-colors-solarized'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tpm'
# For resurrect
# 自动备份时间间隔60min, 默认15min
set -g @continuum-save-interval '60'
set -g @continuum-restore 'on'
set -g @resurrect-capture-pane-contents 'on'
# Use vim keybindings in copy mode
#set-window-option -g mode-keys vi
set-option -g base-index 1
set-option -g renumber-windows on
set -g mouse on # 打开鼠标支持
set-option -g display-time 5000 # 提示信息的持续时间 设置足够的时间以避免看不清提示,单位为毫秒
set-option -g repeat-time 1000 # 控制台激活后的持续时间 避免每次操作都要先激活控制台,单位为毫秒
# auto window rename
set-option -g automatic-rename on
# tmux menu
bind-key A display-menu -x R -y P -T '#[align=centre fg=orange] Commands ' \
'Synchronize Panes' 's' 'set-window-option synchronize-panes' \
'Rename Tab' ',' 'command-prompt -I "#W" { rename-window "%%" }' \
'Run Tmux Command' ':' 'command-prompt'
# status bar
set-option -g status on
set-option -g status-interval 1
set-option -g status-position top
set-option -g status-justify left
set-option -g status-style none,fg=#a89984,bg=#3c3836
# status bar left
set-option -g status-left-length 100
set-option -g status-left-style none
set-option -g status-left '#[fg=#282828,bg=#a89984,nobold] #{E:@OS} Mars #S  #[fg=#a89984,bg=#262626,nobold]'
# status bar right
set-option -g status-right-length 150
set-option -g status-right-style none
set-option -g status-right '#[fg=#a89984,bg=#262626]#[fg=#282828,bg=#a89984] #{E:@GIT_BRANCH} #[fg=#3c3836,bg=#a89984]#[fg=#3c3836]#[fg=#504945,bg=#3c3836]#[fg=#a89984,bg=#504945] #{E:@CPU}%% #[fg=#3c3836]#[fg=#a89984,bg=#504945]  %a %b %d #[fg=#3c3836] #[fg=#a89984,bg=#504945] %H:%M %p #[fg=#3c3836,bg=#504945]'
###{E:@IM}
# window bar style
set-option -g window-status-style 'fg=#3c3836,bg=#504945'
set-option -g window-status-current-style 'fg=#ebdbb2,bg=#49556a'
set-option -g window-status-activity-style 'fg=#3c3836,bg=#504945'
set-option -g window-status-format ' #[fg=#a89984] #I: #W #{?window_last_flag, ,}#{?window_activity_flag,#[fg=#d79921]'
set-option -g window-status-current-format ' #[fg=#ebdbb2] #I:#W #[fg=#689d6a]#{?window_zoomed_flag,,}'
set-option -g window-status-separator ''
set-option -ga terminal-features ',xterm-256color:RGB'
set-option -g default-terminal 'xterm-256color'
# pane border style
set-option -g pane-active-border-style fg='#fe8019'
set-option -g pane-border-style fg='#3c3836'
# mode style
set-option -g mode-style 'bg=brightblack,fg=white,noreverse'
# status variables format
if-shell 'test "$(uname)" = "Darwin"' {
set-option -g @OS ""
set-option -g @IM " #(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleCurrentKeyboardLayoutInputSourceID | awk -F. '{print $4}' | sed s/PinyinKeyboard/中/)"
set-option -g @CPU " #(iostat -c 2 disk0 | sed '/^\s*$/d' | tail -n 1 | awk '{usage=100-$6} END {print(usage)}' | sed 's/,/./')"
} {
set-option -g @OS ""
set-option -g @IM " #(whoami)#{?SSH_CLIENT,@#h,}"
set-option -g @CPU " #(vmstat 1 2 | tail -1 | awk '{usage=100-$15} END {print(usage)}' | sed 's/,/./')"
}
set-option -g @GIT_BRANCH " #(git -C #{pane_current_path} rev-parse --abbrev-ref HEAD || echo ' ')"
# Pane之间切换的快捷键
bind h select-pane -L # 定位到左边窗口的快捷键
bind j select-pane -D # 定位到上边窗口的快捷键
bind k select-pane -U # 定位到下方窗口的快捷键
bind l select-pane -R # 定位到右边窗口的快捷键
# 垂直分割窗格 (Control + D)
bind-key -n C-d split-window -h -c '#{pane_current_path}'
# 水平分割窗格 (Control + Return)
bind-key -n C-g split-window -v -c '#{pane_current_path}'
# 新建选项卡 (Command + T)
bind-key -n C-t new-window -c '#{pane_current_path}'
# 关闭窗格 (Command + W)
bind-key -n C-w kill-pane
# 关闭选项卡 (Command + Shift + W)
bind-key -n C-S-w kill-window
# detach 当前窗口
bind-key -n C-q detach-client
# 访问左边的窗格 (Command + H 或 Command + Left)
bind-key -n C-h select-pane -L
bind-key -n C-Left select-pane -L
# 访问上面的窗格 (Command + J 或 Command + Up)
bind-key -n C-j select-pane -U
bind-key -n C-Up select-pane -U
# 访问下面的窗格 (Command + K 或 Command + Down)
bind-key -n C-k select-pane -D
bind-key -n C-Down select-pane -D
# 访问右边的窗格 (Command + L 或 Command + Right)
bind-key -n C-l select-pane -R
bind-key -n C-Right select-pane -R
# 重命名 Window
bind-key -n C-n command-prompt -p "(rename-window)" "rename-window '%%'"
# 切换选项卡 (Command + 1 到 Command + 9)
bind-key -n M-1 select-window -t :=1
bind-key -n M-2 select-window -t :=2
bind-key -n M-3 select-window -t :=3
bind-key -n M-4 select-window -t :=4
bind-key -n M-5 select-window -t :=5
bind-key -n M-6 select-window -t :=6
bind-key -n M-7 select-window -t :=7
bind-key -n M-8 select-window -t :=8
bind-key -n M-9 select-window -t :=9
bind-key -n C-l send-keys C-l \;
# 切换到上一个选项卡 (Command + [)
bind-key -n C-[ previous-window
# 切换到下一个选项卡 (Command + ])
bind-key -n C-] next-window
### Run TPM Manger
run '~/.tmux/plugins/tpm/tpm'