Files
tmuxifier/libexec/tmuxifier-tmux-version

47 lines
1.1 KiB
Bash
Executable File

#! /usr/bin/env bash
shopt -s extglob
[ -n "$TMUXIFIER_DEBUG" ] && set -x
# Load internal utility functions.
source "$TMUXIFIER/lib/util.sh"
# Provide tmuxifier help
if calling-help "$@"; then
echo "usage: tmuxifier tmux-version [<target-version>]
Outputs current Tmux version. If given optional target-version it outputs one
of three possible characters indicating if the current Tmux version number is
equal to, less than, or greater than the <target-version>.
The three possible outputs are \"=\", \"<\", and \">\"."
exit
fi
version=$(tmux -V)
version=${version/tmux /}
# Fix for tmux next-* versions
version=${version/next-/}
if [ -z "$1" ]; then
echo "$version"
exit
fi
if [ "$version" == "master" ]; then
# When version string is "master", tmux was compiled from source, and we
# assume it's later than whatever the <target-version> is.
echo '>'
else
# Fix for "1.9a" version comparison, as vercomp() can only deal with
# purely numeric version numbers.
version=${version//+([a-zA-Z])/}
vercomp "$version" "$1"
case $? in
0) echo '=' ;;
1) echo '>' ;;
2) echo '<' ;;
esac
fi