Tmux: How do I find out the currently running version of tmux?

Tmux

Tmux Problem Overview


I know that I can run tmux -V to find the version of tmux that is in my PATH, but how can I get the version of tmux that is currently running?

Tmux Solutions


Solution 1 - Tmux

As pointed out in a comment, tmux -V returns the version:

$ tmux -V
# tmux 1.8

Tested on Centos 7 and OSX 10.11.5.

Solution 2 - Tmux

Most obvious, but not 100% correct way is to execute this command in console

$ tmux -V

and receive output like this tmux 2.9a with version of tmux INSTALLED, not currently running. In 99% cases it is enough, but there can be subtle nuances.

Command tmux -V will return version of tmux installed at /usr/bin/tmux or any other directory inside your PATH variable. If you have tmux already running, it is possible that tmux can be started from binary of other version and from different place (for example, tmux can be started from /home/user/bin/tmux). In this case, you have to call

$ ps  -e | grep tmux

to see PID of all tmux processes currently running. It will output something like this

[vodolaz095@ivory ~]$ ps -e | grep tmux
19699 pts/0    00:00:00 tmux: client
19701 ?        00:00:00 tmux: server

Here, number 19701 depicts process id (PID) of currently running tmux server.

After getting PID of tmux server, you can ran command


$ lsof -p 19701

to get information about CURRENTLY RUNNING tmux server process (in my case its 19701) that will output something like this (Figure 1)

COMMAND     PID       USER   FD   TYPE             DEVICE  SIZE/OFF     NODE NAME
tmux:\x20 19701 vodolaz095  cwd    DIR               8,33      4096 22544385 /home/vodolaz095
tmux:\x20 19701 vodolaz095  rtd    DIR                8,1      4096        2 /
tmux:\x20 19701 vodolaz095  txt    REG                8,1    677760  3675332 /usr/bin/tmux
tmux:\x20 19701 vodolaz095  mem    REG                8,1   6406312   131327 /var/lib/sss/mc/group

as you can see, tmux currently running was executed from binary placed in /usr/bin/tmux.

Or, you can call one liner


    lsof -p `pgrep 'tmux: server'`

to achieve the same output as Figure 1

After you get path to tmux binary CURRENTLY RUNNING, (in my case, it was /usr/bin/tmux), you can execute this binary with flag -V to get its version


/usr/bin/tmux -V

or, if tmux was installed by limited user into /home/user/bin/tmux,


/home/user/bin/tmux -V

And, as result, you'll get version of tmux currently running, not the one, that was installed.

Solution 3 - Tmux

To get the version of the tmux server you can use display-message.

./tmux2.3 display-message -p "#{version}"

Will show the version of the server (2.7 in my case)

-p will direct the output of stdout so you can script with it and {version} can be anything from the FORMATS section in the man page.

The following will give you the executable of your tmux server, on linux:

realpath /proc/$(tmux display-message -p "#{pid}")/exe

And on macos, proc_pidpath can be used, see https://stackoverflow.com/a/8149380

Solution 4 - Tmux

To find the actual version of the tmux that is running, you have to find the PID of the tmux:

pgrep tmux

With this info, you can check the version by running:

lsof -p $tmuxPID | grep REG | grep -i -e deleted -e "tmux$"

If there is not a (deleted) next to the tmux file listed, you can just run that file with a -V.

If it results in files that are "(deleted)", you are running an old, uninstalled version. If you are on linux, you can figure out what it is by running:

/proc/$tmuxPID/exe -V`

If you are on OS X, you are stuck with whatever information is in the path to the filename, possibly something like Cellar/tmux/<version number>/bin/tmux.

You can combine many of these steps into the following one-liner:

for tmuxPID in $(pgrep tmux); do lsof -p $tmuxPID | grep REG | grep -i -e deleted -e "tmux$"; done

Or if you are on Linux, this always works:

for tmuxPID in $(pgrep tmux); do /proc/$tmuxPID/exe -V; done

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionquantView Question on Stackoverflow
Solution 1 - Tmuxsixty4bitView Answer on Stackoverflow
Solution 2 - Tmuxvodolaz095View Answer on Stackoverflow
Solution 3 - TmuxwhatintheworldView Answer on Stackoverflow
Solution 4 - TmuxClashTheBunnyView Answer on Stackoverflow