tmux配置文件.tmux.conf (tmux 3.0a)

发布时间 2023-12-14 20:30:37作者: 谁说我是二师兄

本文是基于tmux 3.0a 进行的配置,使用tmux -V可查看版本

下面是配置文件内容,在家目录下创建.tmux.conf,并粘贴下面内容保存后,进入tmux, ctrl+b,然后输入命令:source-file ~/.tmux.conf 即可(或 在bash下执行tmux source ~/.tmux.conf)。

因为下面的命令中,bind了r作为source-file ~/.tmux.conf,所以在输入ctrl+b之后输入 r即可 reloaded

设置完成后,可参照 https://www.cnblogs.com/zhchy89/p/10058005.html 设置懒人启动脚本,以便每次在启动terminal的时候执行命令,直接进入切分好的窗口。

 

#将r 设置为加载配置文件,并显示"reloaded!"信息
bind r source-file ~/.tmux.conf \; display "Reloaded!"


# Use Alt-arrow keys to switch panes
bind -n S-Left select-pane -L
bind -n S-Right select-pane -R
bind -n S-Up select-pane -U
bind -n S-Down select-pane -D

# Shift-arrow to switch windows
bind -n M-Left previous-window
bind -n M-Right next-window


#Enable mouse mode (tmux 2.1 and above)
setw -g mouse on
set -g mouse on

#Enable oh my zsh in tmux
set -g default-command /bin/zsh

# Mouse based copy
bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode MouseDragEnd1Pane send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"

#开启status-bar uft-8支持
#set -g status-utf8 on


#设置终端颜色为256色
set -g default-terminal "screen-256color"
#设置pan前景色
#设置pane背景色
set -g pane-border-style "fg=green,bg=black"
#设置活跃pane前景色
#设置活跃pane背景色
set -g pane-active-border-style "fg=white,bg=yellow"
#设置消息前景色
#设置消息背景色
#设置消息高亮显示
set -g message-style "fg=white,bg=black,bright"
#设置status-bar颜色
set -g status-style "fg=white,bg=black"
#设置窗口列表颜色
setw -g window-status-style "fg=cyan,bg=default,dim"

#设置当前窗口在status bar中的颜色
setw -g window-status-current-style "fg=white,bg=red,bright"
#设置status bar格式
set -g status-left-length 40
set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
set -g status-right "#[fg=cyan]%b %d %R"
set -g status-interval 60
set -g status-justify centre