如何获取自定义 tmux.conf 文件以与 tmux 3.3a 一起使用? `-f` 标志未按预期工作

如何获取自定义 tmux.conf 文件以与 tmux 3.3a 一起使用? `-f` 标志未按预期工作

我有 tmux 并想设置一些自定义配置,但我找不到默认tmux.conf文件。

tmux -V          
tmux 3.3a

根据手册页:

-f file
Specify an alternative configuration file. By default, tmux loads the system configuration file from /etc/tmux.conf, if present, then looks for a user configuration file at ~/.tmux.conf, $XDG_CONFIG_HOME/tmux/tmux.conf or ~/.config/tmux/tmux.conf.

但是,这些位置都没有文件。我创建了~/.tmux.conf,但我在那里所做的任何事情似乎都没有任何效果,即使我运行时tmux -f ~/.tmux.conf我什至在 tmux.conf 中放入了一些随机的废话,希望它会抛出错误消息,但没有运气。

$ cat  ~/.tmux.conf
fdsghdfghhnvn fhgfj dsfgdgh

# Toggle mouse on/off
bind-key m \                  
set-option -gF mouse "#{?mouse,off,on}" \;\
display-message "#{?mouse,Mouse: ON,Mouse: OFF}"

#set color
setw -g status-style fg=white,bg=black


# panes
set -g pane-border-style 'fg=colour19 bg=colour0'
set -g pane-active-border-style 'bg=colour0 fg=colour9'

然而,它显然是从某个地方获取配置:

tmux show -g         
activity-action other
assume-paste-time 1
base-index 0
bell-action any
default-command ''
default-shell /usr/bin/zsh
default-size 80x24
destroy-unattached off
detach-on-destroy on
display-panes-active-colour red
display-panes-colour blue
display-panes-time 1000
display-time 750
history-limit 2000
key-table root
lock-after-time 0
lock-command "lock -np"
message-command-style bg=black,fg=yellow
message-style bg=yellow,fg=black
mouse off
prefix C-b
prefix2 None
renumber-windows off
repeat-time 500
set-titles off
set-titles-string "#S:#I:#W - \"#T\" #{session_alerts}"
silence-action other
status on
status-bg default
status-fg default
status-format[0] "#[align=left range=left #{E:status-left-style}]#[push-default]#{T;=/#{status-left-length}:status-left}#[pop-default]#[norange default]#[list=on align=#{status-justify}]#[list=left-marker]<#[list=right-marker]>#[list=on]#{W:#[range=window|#{window_index} #{E:window-status-style}#{?#{&&:#{window_last_flag},#{!=:#{E:window-status-last-style},default}}, #{E:window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{E:window-status-bell-style},default}}, #{E:window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{E:window-status-activity-style},default}}, #{E:window-status-activity-style},}}]#[push-default]#{T:window-status-format}#[pop-default]#[norange default]#{?window_end_flag,,#{window-status-separator}},#[range=window|#{window_index} list=focus #{?#{!=:#{E:window-status-current-style},default},#{E:window-status-current-style},#{E:window-status-style}}#{?#{&&:#{window_last_flag},#{!=:#{E:window-status-last-style},default}}, #{E:window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{E:window-status-bell-style},default}}, #{E:window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{E:window-status-activity-style},default}}, #{E:window-status-activity-style},}}]#[push-default]#{T:window-status-current-format}#[pop-default]#[norange list=on default]#{?window_end_flag,,#{window-status-separator}}}#[nolist align=right range=right #{E:status-right-style}]#[push-default]#{T;=/#{status-right-length}:status-right}#[pop-default]#[norange default]"
status-format[1] "#[align=centre]#{P:#{?pane_active,#[reverse],}#{pane_index}[#{pane_width}x#{pane_height}]#[default] }"
status-interval 15
status-justify left
status-keys vi
status-left "[#{session_name}] "
status-left-length 10
status-left-style default
status-position bottom
status-right "#{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,}\"#{=21:pane_title}\" %H:%M %d-%b-%y"
status-right-length 40
status-right-style default
status-style bg=green,fg=black
update-environment[0] DISPLAY
update-environment[1] KRB5CCNAME
update-environment[2] SSH_ASKPASS
update-environment[3] SSH_AUTH_SOCK
update-environment[4] SSH_AGENT_PID
update-environment[5] SSH_CONNECTION
update-environment[6] WINDOWID
update-environment[7] XAUTHORITY
visual-activity off
visual-bell off
visual-silence off
word-separators "!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~"
~$ rpm -ql tmux


/run/tmux
/usr/bin/tmux
/usr/lib/tmpfiles.d/tmux.conf
/usr/share/bash-completion/completions/tmux
/usr/share/doc/packages/tmux
/usr/share/doc/packages/tmux/CHANGES
/usr/share/licenses/tmux
/usr/share/licenses/tmux/COPYING

~$ cat /usr/lib/tmpfiles.d/tmux.conf 
d /run/tmux 1777 root root -

我也跑了strace tmux,输出似乎相关,但我不知道该怎么办。

getcwd("/home/james", 4096)             = 12
readlink("/home", 0x7ffcbb31fae0, 1023) = -1 EINVAL (Invalid argument)
readlink("/home/james", 0x7ffcbb31fae0, 1023) = -1 EINVAL (Invalid argument)
readlink("/home", 0x7ffcbb31fae0, 1023) = -1 EINVAL (Invalid argument)
readlink("/home/james", 0x7ffcbb31fae0, 1023) = -1 EINVAL (Invalid argument)
readlink("/etc", 0x7ffcbb320aa0, 1023)  = -1 EINVAL (Invalid argument)
readlink("/etc/tmux.conf", 0x7ffcbb320aa0, 1023) = -1 ENOENT (No such file or directory)
readlink("/home", 0x7ffcbb320aa0, 1023) = -1 EINVAL (Invalid argument)
readlink("/home/james", 0x7ffcbb320aa0, 1023) = -1 EINVAL (Invalid argument)
readlink("/home/james/.tmux.conf", 0x7ffcbb320aa0, 1023) = -1 EINVAL (Invalid argument)
readlink("/home", 0x7ffcbb320aa0, 1023) = -1 EINVAL (Invalid argument)
readlink("/home/james", 0x7ffcbb320aa0, 1023) = -1 EINVAL (Invalid argument)
readlink("/home/james/.config", 0x7ffcbb320aa0, 1023) = -1 EINVAL (Invalid argument)
readlink("/home/james/.config/tmux", 0x7ffcbb320aa0, 1023) = -1 ENOENT (No such file or directory)
access("/usr/bin/zsh", X_OK)            = 0
getuid()                                = 1000

我使用的是 OpenSUSE Tumbleweed。

答案1

好吧,我明白了。我需要做的就是:

tmux kill-server

然后再次运行 tmux ,它使用了我的conf文件而没有指定

相关内容