| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- # vim: set fdm=marker foldenable:
- ########## 基本设置 ---{{{
- #
- # 把 prefix 设置成与 screen 相同,实际上也更好摁一些
- set -g prefix C-a
- unbind-key C-b
- bind-key a send-prefix
- set -g buffer-limit 20000;
- # 快捷键采用 vi 模式
- setw -g mode-keys vi
- # 设置默认 Shell 为 bash,但各平台路径各异,需要分别特殊处理
- if-shell 'test -x /data/data/com.termux/files/usr/bin/bash' {
- set -g default-shell /data/data/com.termux/files/usr/bin/bash
- bind-key -n Home send Escape "OH"
- bind-key -n End send Escape "OF"
- } {
- if-shell 'test -x /usr/local/bin/bash' {
- set -g default-shell /usr/local/bin/bash
- } {
- if-shell 'test -x /usr/bin/bash' {
- set -g default-shell /usr/bin/bash
- } {
- run 'tmux set-option -g default-shell "$(command -v bash)"'
- }
- }
- }
- # }}}
- ########## 终端属性设置 ---{{{
- # 全面开启鼠标支持,鼠标可以用来选择窗口及面板,调整面板尺寸,以及复制文本
- set -g mouse on
- # Use xterm function key sequence
- setw -g xterm-keys on
- # 默认终端
- set -g default-terminal "xterm-256color"
- # Terminal overrides
- set -g set-clipboard on
- set -g terminal-overrides "*88col*:colors=88,*256col*:colors=256,xterm*:colors=256,*256col*:Tc,*:Ms"
- # 这个不能关,关了进了 vim 再退出屏幕画面不会恢复到进入之前
- setw -g alternate-screen on
- # }}}
- ########## 状态栏设置 ---{{{
- #
- # 开启状态栏,并在接下来定制状态栏样式
- set -g status on
- # 不关心其它窗口的事件,对强迫症来说太烦人了
- setw -g monitor-activity off
- # 每隔 10 秒刷新一次状态栏
- set -g status-interval 10
- # 状态栏的窗口列表靠左显示
- set -g status-justify left
- # 状态栏的整体色调背景色为蓝色
- set -g status-style bg=#0000AA
- # 状态栏左部最大长度不超过 32
- set -g status-left-length 32
- # 状态栏左部的格式: 亮品红的日期时间,然后是亮黄色的主机名(#h)
- set -g status-left "#[fg=magenta,bold]%m-%d %H:%M #[fg=brightyellow,bold]#h #[fg=red,bold]| "
- # 状态栏右部最大长度不超过 32
- set -g status-right-length 32
- # 状态栏右部显示内容
- set -g status-right "#[fg=brightyellow]| #(tmux-ui LOGO)#[default]"
- # 状态栏窗口列表中,每个窗口的显示格式: 绿色的编号(#I)及窗口名称(#W)
- setw -g window-status-format '#[fg=green]#I-#(tmux-ui WIN #{pane_title})#[default]'
- # 状态栏窗口列表中,当前窗口的显示格式: 黄色的编号(#I)及窗口名称(#W)
- setw -g window-status-current-format '#[fg=brightyellow]#I-#(tmux-ui WIN #{pane_title})#[default]'
- # 状态栏窗口列表中,有事件的窗口的显示风格
- setw -g window-status-activity-style fg=red,bold,bg=default
- # 状态栏窗口列表中,有喇叭的窗口的显示风格
- setw -g window-status-bell-style fg=red,bold,bg=default
- # Pane 的边框格式
- set -g pane-border-format '#(tmux-ui PANE #{pane_title} #{pane_active} #{pane_width})'
- # 固定给每个 pane 顶部显示一个边框
- set -g pane-border-status top
- # 设置边框颜色
- set -g pane-active-border-style "bg=colour236,fg=cyan bold"
- set -g pane-border-style "bg=colour234,fg=white"
- # tmux 的信息也会显示在状态栏,包括 tmux 的命令行
- set -g message-style fg=brightyellow,bold,bg=red
- # 设置信息显示时间
- set -g display-time 1000
- # }}}
- ########## 窗口管理 ---{{{
- #
- # 窗口的索引值从 0 开始
- set -g base-index 0
- # 关闭中间的会自动重新编号
- # set -g renumber-windows on
- set -g detach-on-destroy off
- # 类似于 screen,用 Ctrl+C 创建窗口,故意映射两组,防止按错
- bind-key C-c new-window -c '#{pane_current_path}'
- bind-key c new-window -c '#{pane_current_path}'
- # 自动设置窗口标题,一旦主动设置过窗口标题,则此窗口不会再次自动设置名称
- setw -g automatic-rename on
- # 通过 Ctrl+n / Ctrl+p 来切换窗口
- bind-key C-n next-window
- bind-key n next-window
- bind-key C-p previous-window
- bind-key p previous-window
- # 快速在两个窗口之间切换
- bind-key C-a last-window
- # 显示所有窗口,以供跳转
- unbind-key l
- bind-key l choose-window
- bind-key k if-shell 'rm tmux/secret 2>/dev/null && exit 0 || touch tmux/secret && exit 1' {
- setw -g window-status-format '#[fg=green]#I-#(tmux-ui WIN #{pane_title})#[default]'
- } {
- # 但如果是隐私模式则只显示星号
- setw -g window-status-format '#[fg=green]#I-****#[default]'
- }
- bind-key K if-shell 'rm tmux/secret 2>/dev/null && exit 0 || touch tmux/secret && exit 1' {
- setw -g window-status-format '#[fg=green]#I-#(tmux-ui WIN #{pane_title})#[default]'
- setw -g window-status-current-format '#[fg=brightyellow]#I-#(tmux-ui WIN #{pane_title})#[default]'
- set -g pane-border-format '#(tmux-ui PANE #{pane_title} #{pane_active} #{pane_width})'
- } {
- # 但如果是隐私模式则只显示星号
- setw -g window-status-format '#[fg=green]#I-****#[default]'
- setw -g window-status-current-format '#[fg=brightyellow]#I-****#[default]'
- set -g pane-border-format ''
- }
- # }}}
- ########## 面板管理 ---{{{
- #
- # 显示面板编号,方便跳转,以及通过样式得知哪个是当前面板
- bind-key m display-pane
- bind-key C-m display-pane
- set -g display-panes-time 3000
- set -g display-panes-active-colour brightblack
- set -g display-panes-colour brightyellow
- # 通过 | 和 - 来切分窗口
- unbind %
- unbind '"'
- bind | split-window -h -c '#{pane_current_path}'
- bind - split-window -v -c '#{pane_current_path}'
- bind-key o last-pane
- bind-key C-o last-pane
- bind-key w select-pane -t :.+
- bind-key Tab select-pane -t :.+
- # }}}
|