Tmux_conf

参考链接

创建tmux配置文件

touch ~/.tmux.conf

配置文件代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
  # Send prefix
  set-option -g prefix C-a
  unbind-key C-a
  bind-key C-a send-prefix
  # Use Alt-arrow keys to switch panes
  bind -n M-Left select-pane -L
  bind -n M-Right select-pane -R
  bind -n M-Up select-pane -U
  bind -n M-Down select-pane -D
  # Shift arrow to switch windows
  bind -n S-Left previous-window
  bind -n S-Right next-window
  # Mouse mode
  set -g mouse on
  # Set easier window split keys
  bind-key v split-window -h
  bind-key h split-window -v
  # Easy config reload
  bind-key r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded"

修改Tmux的Ctrl+B前缀快捷键

在电脑上ctrl+b是往前移动一个字符

1.查看prefix现有绑定键:

1
tmux show-options -g | grep prefix

2.要在tmux内置命令中修改及时生效,可在终端中输入以下命令:(只对当前这一次登录有效,关机后失效)其中第一个-g设置全局生效快捷键。其实一般第一个设置好后新的快捷键就可以生效,如果需要再使用第二个和第三个命令。

1
2
3
4
5
tmux set -g prefix C-x
 
tmux unbind C-b 
 
tmux bind C-x send-prefix

3.要永久生效,则在创建或修改系统级的/etc/tmux.conf或用户级的~/.tmux.conf 首先打开文件:

1
vim ~/.tmux.conf

然后在文件中输入三个命令

1
2
3
4
5
set -g prefix C-x
 
unbind C-b
 
bind C-x send-prefix

然后让他生效:

1
source ~/.tmux.conf

或者重启也可以让他生效

Licensed under CC BY-NC-SA 4.0