刚刚通过homebrew
安装了tmux,我正试图找到系统范围的tmux配置文件。手册页指出系统范围的文件应该位于/etc/tmux.conf
,但由于某种原因它不在那里。默认tmux.conf
文件位于何处?
注意:目前正在运行OSX Mavericks
答案 0 :(得分:12)
据我所知,通过自制软件安装的tmux没有系统范围的conf文件。如果您确实需要,可以在/etc/tmux.conf
添加自己的。但是,我想知道需要这个。我把配置放在~/.tmux.conf
中,一切都很开心。
有一个/usr/local/Cellar/tmux/1.8/etc
目录,但它包含bash完成脚本。我还检查了usr/local/etc
它没有安装配置。
我非常有信心,通过自制软件的tmux安装程序不会安装它自己的系统范围的配置文件,而是将其作为sys管理员的练习,如果需要这样的功能的话。
答案 1 :(得分:2)
你应该找到一些有用的东西:
/usr/share/doc/tmux/examples
最新版本的tmux只有示例conf文件,它不是OSX问题,只是新的默认tmux包装。所以你可以使用任何像这样的东西:
$cp /usr/share/doc/tmux/examples/someconffile.conf ~/.tmux.conf
应该这样做。
答案 2 :(得分:1)
默认情况下,tmux没有可编辑的系统范围配置。它已被纳入该计划。
使用这些命令列出已编译的默认值,然后为您的用户创建自己的文件。
tmux list-keys # show current bindings
tmux show-options -s # show current server options
tmux show-options -g # show current global session options
tmux show-options # show current session options
tmux show-options -gw # show current global window options
tmux show-options -w # show current window options
使用tmux 1.7,show-options还可以显示单个选项的值(之前的版本只能列出指定类中的所有选项):
tmux show-options -gw window-status-format
答案 3 :(得分:0)
“我会对它采取一些措施。这里有一些解决方案。我不运行Mac,但我运行RH,Debian,FreeBSD和Solaris,CYgwin和其他东西。
我的理解直接来自man tmux
。 -f
标志将指定备用配置文件。默认情况下,tmux
从/etc/tmux.conf
加载系统配置文件(如果存在),然后在~/.tmux.conf
查找用户配置文件。配置文件是一组tmux
命令,在首次启动服务器时按顺序执行。
#!/usr/bin/env bash
unset temporary_array_tmp ; declare -a temporary_array_tmp
temporary_array_tmp=(/etc/tmux.conf ~/.tmux.conf)
# The next line creates an empty global and personal configuration file,
# if it individually does NOT exists.
for i_tmp in "${temporary_array_tmp[@]}" ; do
[[ ! -f "${i_tmp}" ]] && \
touch "${i_tmp}" && \
echo -en "I created an empty tmux configuration file @ ${i_tmp}. " && \
echo -e "You need to add configuration settings to ${i_tmp} ." || \
echo -e "The tmux configuration file ${i_tmp} already exists."
done
# After you add configuration settings, then you need
# to tell tmux to reload the files.
for i_tmp in "${temporary_array_tmp[@]}" ; do
[[ -f "${i_tmp}" ]] && \
tmux source-file "${i_tmp}" && \
echo -e "${i_tmp} The tmux configuration file ${i_tmp} is loaded." || \
echo -e "The tmux configuration file ${i_tmp} is NOT loaded."
done
unset temporary_array_tmp
接下来,您可以使用find
找到tmux目录和/或文件。例如:
find ~/ /etc /usr -iname *tmux*
答案 4 :(得分:0)
来自man tmux
页:
-f file Specify an alternative configuration file. By default, tmux loads the system configuration file from /usr/local/etc/tmux.conf, if present, then looks for a user configuration file at
~/.tmux.conf.
如果没有文件,则可以使用touch ~/.tmux.conf
创建一个文件,然后编写任何内容。
答案 5 :(得分:0)
Alon Gouldman's answer为我工作。只需添加:
在Ubuntu 20.04上工作时遇到了这个问题。
这是我的解决方法:
首先,如果在您的主目录中找不到任何用于tmux的配置文件,请使用以下命令在您的 home (~
)目录中创建一个文件:
touch ~/.tmux.conf
接下来,要使文件在每次启动 Tmux 会话时始终可用,请将文件添加到~/.bash_profile
,~/.bash_login
和~/.profile
中文件。应该将其添加到文件的底部:
source "$HOME/.tmux.conf"
这是一个例子:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
source "$HOME/.tmux.conf"
注意:~/.bash_profile
文件具有第一个优先级,然后是~/.bash_login
文件作为第二个优先级,然后是~/.profile
文件作为最后的优先级
仅此而已。
我希望这会有所帮助