Dotfiles
约 959 字
预计阅读 2 分钟
次阅读
tmux
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
|
# 基本设置
set-option -g history-limit 100000 # 提高历史记录限制,适合查看长时间的输出
set-option -g mouse on # 启用鼠标支持
set-option -g default-terminal "screen-256color" # 开启 256 色支持
set-option -g prefix C-a # 更改前缀键为 Ctrl + a
unbind C-b # 取消 Ctrl + b 作为前缀键
bind C-a send-prefix # Ctrl+a Ctrl+a 发送原始 Ctrl+a(如跳到行首)
# 复制模式使用 vi 按键风格(必须有这行,否则 v/y 等绑定不生效)
set-window-option -g mode-keys vi
# 窗格管理
bind '"' split-window -v # 前缀键 + " 垂直分屏(上下)
bind '%' split-window -h # 前缀键 + % 水平分屏(左右)
# 快速切换窗格
bind h select-pane -L # 切换到左侧窗格
bind j select-pane -D # 切换到下方窗格
bind k select-pane -U # 切换到上方窗格
bind l select-pane -R # 切换到右侧窗格
# 更改窗格大小
bind -r H resize-pane -L 5 # 左调整窗格大小
bind -r J resize-pane -D 5 # 下调整窗格大小
bind -r K resize-pane -U 5 # 上调整窗格大小
bind -r L resize-pane -R 5 # 右调整窗格大小
# 复制模式和粘贴
unbind -T copy-mode-vi v
bind -T copy-mode-vi v send -X begin-selection # v 开始选择(像 vim visual mode)
bind -T copy-mode-vi V send -X select-line # V 选整行
bind -T copy-mode-vi C-v send -X rectangle-toggle # Ctrl+v 块选择
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "pbcopy" # y 复制并同步到系统剪贴板,退出复制模式
bind -T copy-mode-vi Escape send -X cancel # Esc 退出复制模式
bind p paste-buffer # 前缀键 + p 粘贴
# 鼠标拖选后自动复制到系统剪贴板
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
# 状态栏优化
set-option -g status-interval 2 # 每 2 秒刷新状态栏
set-option -g status-left "#[fg=green](#S) " # 显示会话名
set-option -g status-right "" # 不显示时间
# 改进外观
set-option -g status-bg black # 状态栏背景色
set-option -g status-fg green # 状态栏前景色
set-window-option -g window-status-current-style bg=blue,fg=white # 当前窗口的状态栏样式
# 快速重载配置文件
bind r source-file ~/.tmux.conf \; display-message "Tmux 配置已重载" # 前缀键 + r 重载配置
|
vim
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
|
" 启用混合行号
set number relativenumber
" 启用语法高亮
syntax on
" 自动检测文件类型,加载相应插件和缩进规则
filetype plugin indent on
" 设置缩进相关配置
set tabstop=4 " 一个 tab 键对应 4 个空格
set shiftwidth=4 " 自动缩进使用 4 个空格
set expandtab " 将 tab 转换为空格
set autoindent " 自动缩进
set smartindent " 根据语法自动调整缩进
" 搜索时忽略大小写,除非有大写字母
set ignorecase
set smartcase
" 实时高亮搜索结果
set hlsearch
" 但一旦你移动光标,高亮将被自动取消
autocmd CursorMoved * :nohlsearch
" 输入搜索模式时增量显示匹配结果
set incsearch
" 显示光标当前位置的状态行
set ruler
" 启用状态栏
set laststatus=2
" 启用命令行补全
set wildmenu
" 启用光标下方 8 行预留显示
set scrolloff=6
" 高亮当前行
set cursorline
" 显示匹配的括号
set showmatch
" 启用多级撤销
set undofile
set undodir=~/.vim/undodir " 保存撤销历史的目录
" 减少更新屏幕的时间间隔(更快的响应速度)
set updatetime=300
" 减少交换文件写入的频率
set lazyredraw
|