步骤
touch ~/.tmux.conf
创建tmux配置文件
- 修改文件内容,增加一行
set -g mouse on
并保存
- 执行
tmux source-file ~/.tmux.conf
让配置生效
这时候tmux就可以使用鼠标来选中窗口,tail 日志时候也可以支持鼠标滚轮滚动了
但是此时用鼠标选中内容并复制会出现问题,选中松开鼠标会自动失去焦点,需要在选择文本时候同时按住option
键就可以了
Update@2023年07月28日
折腾了几天后分享网上找到一个配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# set-option -g prefix C-a
# unbind-key C-b
# bind-key C-a send-prefix
set -g mouse on
#################### 全局配置 ####################
# 热键替换
# unbind C-b
# set -g prefix C-s
# "C-s R" 重载 tmux 配置
bind R source-file ~/.tmux.conf \; display-message "Tmux Config reloaded..."
# "C-s s" 选择 session 顺序调整
bind s choose-tree -s -r -O name -K ''
# "C-s m" 切换鼠标支持
bind m run-shell 'if [ "$(tmux show-option -gq mouse)" == "mouse on" ]; then tmux set -g mouse off; else tmux set -g mouse on; fi'\; display-message "Mouse Switched..."
# OSC 52
# https://github.com/tmux/tmux/wiki/Clipboard
set -s set-clipboard on
#################### 窗口配置 ####################
# 窗口重命名
set -w -g allow-rename on
set -w -g automatic-rename on
# 窗口号和窗口分割号从 1 开始
set -g base-index 1
set -w -g pane-base-index 1
# 窗口操作默认按键绑定
set -w -g mode-keys vi
# 终端颜色
# 此颜色应当与所使用终端配置一致,当前为 Alacritty
set -g default-terminal "xterm-256color"
# -a: append
set -ga terminal-overrides ",xterm-256color:Tc:clipboard"
# 防止自动关闭 Session
set -g destroy-unattached off
#################### 状态栏 ####################
# 状态栏位置
set -g status-position top
# 颜色
set -g status-bg default
set -g status-fg white
# 刷新时间
set -g status-interval 1
# 对齐方式
set -g status-justify centre
# 左下角
set -g status-left '#[fg=brightcyan]#S'
set -g status-left-length 20
# 右下角
set -g status-right '#[fg=brightcyan][%H:%M]'
# 状态栏颜色
set -g status-style fg=brightgreen
# 消息颜色
set -g message-style fg=brightgreen
# 默认窗口标题颜色
set -w -g window-status-format '#[dim]#I:#W'
# 当前窗口标题颜色
set -w -g window-status-current-format '#[fg=brightcyan,bold]#I:#W'
# pane border
#set -g pane-border-style fg=brightred
#set -g pane-active-border-style fg=brightgreen
# pane number display
set -g display-panes-active-colour brightgreen
set -g display-panes-colour brightyellow
#################### Plugins ####################
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
#set -g @plugin 'MunifTanjim/tmux-mode-indicator'
set -g @plugin 'MunifTanjim/tmux-suspend'
set -g @suspend_key 'F12'
# remove colors from status line for suspended state
set -g @suspend_suspended_options " \
status-left::#[bg=brightblack]--------, \
status-right::#[bg=brightblack][-----], \
window-status-current-format::#[bg=brightblack]-----
"
run '~/.tmux/plugins/tpm/tpm'
#################### WorkSpaces ####################
# init workspace
#new-session -d -s '🍁 local'
#new-session -d -s '🌋 test'
#new-session -d -s '🌀 prod'
# custom hook(mmh auto change context)
#set-hook -t '🌋 test' client-session-changed 'run-shell "mcx yt-test > /dev/null"'
#set-hook -t '🌀 prod' client-session-changed 'run-shell "mcx yt-prod > /dev/null"'
|