默认 tmux 配置

默认 tmux 配置

我一直在尝试一些.tmux.conf文件,但现在我想返回到原始/默认配置。我该怎么做?我一直在寻找默认文件,但没有成功。

答案1

以下是取自 1.51 版的默认选项列表window-options.c在 OpenBSD-current 的 tmux 源代码中(这是开发版本,经常与 sourceforge 同步)。

# Server options.
buffer-limit  20
escape-time  500
exit-unattached  0
focus-events  0
message-limit  100
quiet  0
set-clipboard  1
terminal-overrides  "*256col*:colors=256,xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007:Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007:Ss=\\E[%p1%d q:Se=\\E[2 q,screen*:XT"

# Session options.
assume-paste-time  1,
base-index  0
bell-action  any
bell-on-alert  0
default-command  ""
default-shell  _PATH_BSHELL
default-terminal  "screen"
destroy-unattached  0
detach-on-destroy  1
display-panes-active-colour  1
display-panes-colour  4
display-panes-time  1000
display-time  750
history-limit  2000
lock-after-time  0
lock-command  "lock -np"
lock-server  1
message-attr  0,
message-bg  3,
message-command-attr  0,
message-command-bg  0,
message-command-fg  3,
message-command-style  "bg=black,fg=yellow"
message-fg  0,
message-style  "bg=yellow,fg=black"
mouse-resize-pane  0
mouse-select-pane  0
mouse-select-window  0
mouse-utf8  0
pane-active-border-bg  8,
pane-active-border-fg  2,
pane-active-border-style  "fg=green"
pane-border-bg  8,
pane-border-fg  8,
pane-border-style  "default"
prefix C-b
prefix2  KEYC_NONE,
renumber-windows  0
repeat-time  500
set-remain-on-exit  0
set-titles  0
set-titles-string  "#S:#I:#W - \"#T\""
status  1
status-attr  0,
status-bg  2,
status-fg  0,
status-interval  15
status-justify  0
status-keys emacs
status-left  "[#S] "
status-left-attr  0,
status-left-bg  8,
status-left-fg  8,
status-left-length  10
status-left-style  "default"
status-position  1
status-right  " \"#{=22:pane_title}\" %H:%M %d-%b-%y"
status-right-attr  0,
status-right-bg  8,
status-right-fg  8,
status-right-length  40
status-right-style  "default"
status-style  "bg=green,fg=black"
status-utf8  0 # overridden in main()
update-environment  "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY"
visual-activity  0
visual-bell  0
visual-silence  0
word-separators  " -_@"

# Window options.
aggressive-resize  0
allow-rename  1
alternate-screen  1
automatic-rename  1
automatic-rename-format  "#{?pane_in_mode,[tmux],#{pane_current_command}}#{?pane_dead,[dead],}"
c0-change-trigger  250,
c0-change-interval  100,
clock-mode-colour  4
clock-mode-style  1
force-height  0
force-width  0
main-pane-height  24
main-pane-width  80
mode-attr  0,
mode-bg  3,
mode-fg  0,
mode-keys  emacs
mode-mouse  0
mode-style  "bg=yellow,fg=black"
monitor-activity  0
monitor-silence  0
other-pane-height  0
other-pane-width  0
pane-base-index  0
remain-on-exit  0
synchronize-panes  0
utf8  0 # overridden in main()

wrap-search  1
xterm-keys  0

# XXX: not sure how to transcribe these
window-status-activity-attr  GRID_ATTR_REVERSE,
window-status-activity-bg  8,
window-status-activity-fg  8,
window-status-activity-style  "reverse"
window-status-attr  0,
window-status-bell-attr  GRID_ATTR_REVERSE,
window-status-bell-bg  8,
window-status-bell-fg  8,
window-status-bell-style  "reverse"
window-status-bg  8,
window-status-current-attr  0,
window-status-current-bg  8,
window-status-current-fg  8,
window-status-current-format  "#I:#W#F"
window-status-current-style  "default"
window-status-fg  8,
window-status-format  "#I:#W#F"
window-status-last-attr  0,
window-status-last-bg  8,
window-status-last-fg  8,
window-status-last-style  "default"
window-status-separator  " "
window-status-style  "default"

key-bindings.c 中的默认键绑定

 bind C-b send-prefix
 bind C-o rotate-window
 bind C-z suspend-client
 bind Space next-layout
 bind ! break-pane
 bind '\"' split-window
 bind '#' list-buffers
 bind '$' command-prompt -I'#S' \"rename-session '%%'\"
 bind % split-window -h
 bind & confirm-before -p\"kill-window #W? (y/n)\" kill-window
 bind \"'\" command-prompt -pindex \"select-window -t ':%%'\"
 bind ( switch-client -p
 bind ) switch-client -n
 bind , command-prompt -I'#W' \"rename-window '%%'\"
 bind - delete-buffer
 bind . command-prompt \"move-window -t '%%'\"
 bind 0 select-window -t:0
 bind 1 select-window -t:1
 bind 2 select-window -t:2
 bind 3 select-window -t:3
 bind 4 select-window -t:4
 bind 5 select-window -t:5
 bind 6 select-window -t:6
 bind 7 select-window -t:7
 bind 8 select-window -t:8
 bind 9 select-window -t:9
 bind : command-prompt
 bind \\; last-pane
 bind = choose-buffer
 bind ? list-keys
 bind D choose-client
 bind L switch-client -l
 bind [ copy-mode
 bind ] paste-buffer
 bind c new-window
 bind d detach-client
 bind f command-prompt \"find-window '%%'\"
 bind i display-message
 bind l last-window
 bind n next-window
 bind o select-pane -t:.+
 bind p previous-window
 bind q display-panes
 bind r refresh-client
 bind s choose-tree
 bind t clock-mode
 bind w choose-window
 bind x confirm-before -p\"kill-pane #P? (y/n)\" kill-pane
 bind z resize-pane -Z
 bind { swap-pane -U
 bind } swap-pane -D
 bind '~' show-messages
 bind PPage copy-mode -u
 bind -r Up select-pane -U
 bind -r Down select-pane -D
 bind -r Left select-pane -L
 bind -r Right select-pane -R
 bind M-1 select-layout even-horizontal
 bind M-2 select-layout even-vertical
 bind M-3 select-layout main-horizontal
 bind M-4 select-layout main-vertical
 bind M-5 select-layout tiled
 bind M-n next-window -a
 bind M-o rotate-window -D
 bind M-p previous-window -a
 bind -r M-Up resize-pane -U 5
 bind -r M-Down resize-pane -D 5
 bind -r M-Left resize-pane -L 5
 bind -r M-Right resize-pane -R 5
 bind -r C-Up resize-pane -U
 bind -r C-Down resize-pane -D
 bind -r C-Left resize-pane -L
 bind -r C-Right resize-pane -R

还有进一步的键绑定(vi 和 emacs 复制模式和状态行编辑键)定义在mode-keys.c我没有费心去提取。

答案2

您可以使用以下命令获取默认设置

$ tmux -f /dev/null show-options -s \; show-options -g \; list-keys > tmux.defaults.conf

-f /dev/null指定了一个空配置文件,因此您最终得到的是源代码中硬编码的内容。

一旦将其捕获到文件中,您就可以,理论上,将其用作源文件:

$ tmux unbind-key -a
$ tmux source-file tmux.defaults.conf

我说理论上因为您需要在提取的内容中进行转义,tmux.conf然后才能正确获取。可以unbind-key在加载tmux.conf.我不确定是否有办法集体清除选项。

答案3

其他答案包括一些非常有用的信息,这些信息暗示了答案,但我认为他们还没有完全明确地回答这个问题。

如果我正确理解 tmux 手册页,您可以使用 .reset 将给定选项重置为默认值tmux set -u -g <option>

我知道一次性恢复所有选项的唯一方法是重新安装 tmux。

我认为 ariane 提供的参考(或至少部分)是在使用tmux show -gtmux show -g -s和来安装 tmux 后立即生成的,tmux show -g -w以获取会话、服务器和窗口选项。

答案4

tmux从编译的值中获取默认值,/etc/tmux.conf然后由否决~/.tmux.conf。如果后者不存在,它将仅适用于其他值。这意味着您可以删除~/.tmux.conf或将其留空。

在 Ubuntu 12.04 和 Linux Mint 17 上似乎都有一个默认/etc/tmux.conf文件(在这种情况下,将采用编译后的默认值)。

相关内容