Brandon Mercer
Brandon Mercer

Reputation: 433

Tmux: missing tmux config file?

Just installed tmux via homebrew and I'm trying to locate the system-wide tmux configuration file. The man pages state that the system-wide file should be located in /etc/tmux.conf, but for some reason, it is not there. Where is the default tmux.conf file located?

Note: Currently running OSX Mavericks

Upvotes: 20

Views: 52189

Answers (6)

Promise Preston
Promise Preston

Reputation: 28800

Alon Gouldman's answer worked for me. Just to add to it:

I had this issue when working on Ubuntu 20.04.

Here's how I solved it:

Firstly, if do not find any configuratio file for tmux in your home directory, then create one inside your home (~) directory using the command:

touch ~/.tmux.conf

Next, to make the file to be always available whenever you start a Tmux session add the file to either the ~/.bash_profile, ~/.bash_login, and ~/.profile file. It should be added at the bottom of the file:

source "$HOME/.tmux.conf"

Here's an example:

# ~/.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"

Note: The ~/.bash_profile file takes the first precedence, then the ~/.bash_login file as the second precedence, and then the ~/.profile file as the last precedence.

That's all.

I hope this helps

Upvotes: 0

Alon G
Alon G

Reputation: 3373

from the man tmux page:

     -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.

If there is no file, you can just create one using touch ~/.tmux.conf and write whatever you want.

Upvotes: 3

MyMightyJoeYoung
MyMightyJoeYoung

Reputation: 19

"I will take a crack at it. Here are some solutions off the top of my head. I do not run Mac but I run RH, Debian, FreeBSD, and Solaris, CYgwin and other stuff.

My understanding which is taken straight from man tmux. The -f flag will 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. The configuration file is a set of tmux commands which are executed in sequence when the server is first started.

#!/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

Mentionable Notes

Next you can find tmux directories and/or files using find. For example:

find ~/ /etc /usr -iname *tmux*

Upvotes: -1

dynabaul
dynabaul

Reputation: 181

By default tmux doesn't have a system-wide config that is editable. It's complied into the program.

Use these commands to list out the compiled defaults, then make your own file with it for your user.

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

With tmux 1.7, show-options can also show you the value of a single option (prior versions can only list all the options from the specified class):

tmux show-options -gw window-status-format

Upvotes: 6

deadPoet
deadPoet

Reputation: 538

You should find something useful in:

/usr/share/doc/tmux/examples

recent versions of tmux only have the examples conf files, it's not an OSX issue, just new default tmux packaging. So you can use any of those doing something like:

$cp /usr/share/doc/tmux/examples/someconffile.conf ~/.tmux.conf

that should do it.

Upvotes: 2

Sukima
Sukima

Reputation: 10064

As far as I can tell the tmux installed via homebrew does not have a system wide conf file. If you did need one you could add your own at /etc/tmux.conf. However, I would wonder the need for this. I place my config in ~/.tmux.conf and everything is very happy.

There is a /usr/local/Cellar/tmux/1.8/etc directory but it houses the bash completion scripts. I also checked usr/local/etc it it to did not have an installed config.

I'm pretty confident at this point that the tmux installer via homebrew does not install it's own system wide config file instead leaving that as an exercise for the sys admin if such a feature was required.

Upvotes: 19

Related Questions