将 tmux.conf 拆分成多个文件?

Split tmux.conf into multiple files?

我有一个在计算机之间共享的常用 tmux 设置文件 (tmux.conf.common)。我希望能够在我的 tmux.conf 中获取此文件。在 bash 中实现此目的的一种方法是让每台计算机的 .bashrc 源通用文件。有没有办法在 tmux 中做类似的事情?

.tmux.conf格式有source-file指令,可以用同样的方式使用。使用 source 也有效。

source-file /path/to/tmux.conf.common

有点晚了,但这就是我在我的工作站和部署的服务器上使用它的方式,以便能够共享我的一般偏好并轻松覆盖它们。

首先,我只是将我的 .tmux.conf 移动到 tmux.common,然后将其放在现在空的 tmux.conf 中 然后我将这个基本的 tmux.conf tmux.common 分发给所有节点。

因为 tmux.common 中的最后一行是 运行 '~/.tmux/plugins/tpm/tpm' 需要在源文件之前提及任何其他插件。

如果需要,这可以很容易地扩展以包含更多常见文件,例如使 devel/test / acceptance/production 系统具有不同的颜色或诸如此类的东西。

通用。tmux.conf

#
# Include commons settings, shared between systems, anything but plugin
# related stuff can come after, like overriding common bindings or settings.
# Plugin stuff needs to be specified before this!
#
source-file ~/nocloud/conf/tmux.common

工作站.tmux.conf

在我的工作站上,我使用了一个布局插件,这有助于让我知道 tmux 会话是本地的还是远程的,如果是远程的,我必须仔细查看主机名,以确保我在做任何事情到右边。

set -g @plugin "arcticicestudio/nord-tmux"

#
# Include commons settings, shared between systems, anything but plugin
# related stuff can come after, like overriding common bindings or settings.
# Plugin stuff needs to be specified before this!
#
source-file ~/Dropbox/SharedConfigs/multi-os-apps/tmux.common