0

I'm compiling tmux from its source code via a script which looks like this:

set -e
DIR="${HOME}/Programs/"
build() {
  [[ -d "${DIR}" ]] || mkdir -p "${DIR}"
  cd "${DIR}"
  if [[ ! -d tmux ]]; then
    git clone https://github.com/tmux/tmux
  fi
  cd tmux
  git stash
  git checkout master
  git pull
  make clean; make distclean
  sh autogen.sh
  ./configure
  make
}
install() {
  dpkg -r tmux
  checkinstall --pkgname tmux --pkgversion '9999:9999.9999' -y
}
build
install

It compiles and installs tmux, as expected.
But there's still one issue, which is the version reported by $ tmux -V:

$ tmux -V
tmux master

It reports tmux master, while I would prefer tmux X.Y, X.Y being the version of the latest release. For example, at the moment, the latest release is 2.8, so I would like $ tmux -V to output tmux 2.8.

Is there any way to change this output?

I've looked at the output of ./configure --help, and searched for an option to set the version of the tmux process, but couldn't find one.

For the moment, I've included a sed command in my script so that it automatically edits the file configure.ac, and assigns a big version number 99.99 (I don't know how to programmatically get the version number of the latest release):

sh autogen.sh
sed -i 's/AC_INIT(tmux, master)/AC_INIT(tmux, 99.99)/' configure.ac
./configure

Is there a better way?


The reason why I ask this question is because I use the tmux-open plugin, which doesn't work as expected when $ tmux -V outputs tmux master.

The latter uses this line of code to determine the version of the current tmux process:

$ tmux_version="$(tmux -V | cut -d ' ' -f 2)"

The plugin then uses this variable to determine the syntax of the commands installing key bindings.

The key bindings are not installed on my machine, and I think it's due to the output of $ tmux -V. Because if I replace this line in the plugin:

if [[ $tmux_version == $1 ]]

with this line:

if [[ $tmux_version == $1 ]] || [[ $tmux_version == 'master' ]]

Then the plugin correctly installs its key bindings.

  • 1
    Does git describe or ... tag show anything useful? – Jeff Schaller Sep 14 '18 at 19:34
  • @JeffSchaller Ah yes, you're right git describe gives 2.8-66-g71d2ab1. I'll use this as the version number, thank you very much. – user938271 Sep 14 '18 at 19:37
  • 1
    I think if you set the VERSION env variable before running configure that will set the version in the right .h file. So VERSION=2.8-66-g71d2ab1 ./configure && make – Cupcake Protocol Sep 14 '18 at 19:40
  • @CupcakeProtocol I've tried VERSION="$(git describe)" ./configure && make, and VERSION=2.8-66-g71d2ab1 ./configure && make, but both give the same output tmux master. Maybe I should use another variable, though. Anyway, thank you very much for the suggestion. – user938271 Sep 14 '18 at 19:47
2

insert a line like:

sed '/AC_INIT/s/master/m4_esyscmd_s([git describe])/' -i configure.ac

before the sh autogen.sh call in your script.

based on the answer here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.