tmux 配置文件
tmux 大法好,对 bash 窗口进行复用,再也不需要开一堆窗口,然后不停 <A-Tab>
了。
为了全键盘操作,很有必要对 tmux 的默认设置进行修改。当然,作为一个 vim 党,我会按照 vim 的操作习惯改。
tmux 配置文件为 ~/.tmux.conf
直接上配置文件:
# 禁用鼠标
setw -g mouse off
# 类 vi 设置
setw -g mode-keys vi
# 复制选项
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-selection
bind -t vi-copy y copy-pipe "xclip -sel clip -i"
# 移动
bind j select-pane -D
bind k select-pane -U
bind h select-pane -L
bind l select-pane -R
# 分割面板
unbind '"'
bind - splitw -v
unbind %
bind | splitw -h
# 重读取配置文件
bind r source-file ~/.tmux.conf \; display "tmux reloaded!"
# tmux 响应快捷键速度
set -sg escape-time 1
# 提示信息停留时间
set -g display-time 3000
# 窗口间移动 bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
bind -r C-h select-window -t :-
# 调节面板大小
bind -r H resize-pane -L 3
bind -r J resize-pane -D 3
bind -r K resize-pane -U 3
bind -r L resize-pane -R 3
# 彩色命令行显示
set -g default-terminal "screen-256color"
# -r 持续时间
set -g repeat-time 5000
# 通知配色
set -g message-fg white
set -g message-bg black
set -g message-attr bright
# 状态栏配置
set -g status-fg white
set -g status-bg black
setw -g window-status-fg colour15
setw -g window-status-bg black
setw -g window-status-attr dim
setw -g window-status-current-bg colour250
set -g status-fg white
set -g status-bg black
set -g status-left-length 40
set -g status-left "#[fg=green]Ses: #S #[fg=yellow]Win: #I #[fg=cyan]Pane: #P"
set -g status-right "#[fg=colour250]%D #[fg=]%R"
set -g status-justify centre
有些教程推荐用<C-A>
代替<C-B>
作为 tmux 的 bind-key。但也提到,可能有<C-A>
与命令行或者 vim 原有快捷键冲突的情况。
个人觉得<C-B>
挺好用(可能是手指长的缘故吧),因此没进行修改,也避免了一些破事(比如将 bind-key 传递到进程中)。
ps: 需要安装 xclip 以便复制到系统剪切板
sudo apt install xclip