Tmux 不会读取 ~/.tmux.conf

Tmux won't read ~/.tmux.conf

我正在 运行 通过 SSH 在另一台机器上进行 tmux 会话。我的 ~/.tmux.conf 看起来如下:

# set Ctrl-a as the default prefix key combination
# and unbind C-b to free it up
set prefix C-a
unbind-key C-b

如您所见,没什么特别的。通过使用 killall tmuxtmux kill-server,我确保没有剩余的 tmux 会话是 运行。当启动一个新的 tmux 会话时,前缀似乎是 C-b,所以我最好的猜测是我的 conf 没有加载。使用 C-b + :source-file ~/.tmux.conf 时,我的前缀更改为 C-a。通过 Yum 安装 tmux,无法使用 yum 将其更新到更高版本。

$ tmux -V
tmux 1.6

这是怎么回事?

首先,您必须确保 .tmux.conf 位于您的远程机器 $HOME 上,而不是您的本地 $HOME.

在文件中,你可以试试这个(评论中的解释):

unbind C-b  
set -g prefix C-a # change prefix key to Ctrl-a as global opt, same as gnu screen
bind a send-prefix #send ^A, so that you can press ctrl-a a to send ctrl-a

顺便说一句,您可以在没有 root 权限的情况下为您的本地用户编译和安装新的 tmux。

因为你忘记在配置结束时绑定发送前缀。添加以下行,它会成功:)

bind-key C-a send-prefix