# libtmux.common.get_version

- **Module:** libtmux.common
- **Package:** libtmux
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/common.py#L472
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-common-get_version/

```
libtmux.common.get_version(
    tmux_bin: str | None = None,
) -> LooseVersion
```

Return tmux version.

If tmux is built from git master, the version returned will be the latest
version appended with -master, e.g. ``2.4-master``.

If using OpenBSD's base system tmux, the version will have ``-openbsd``
appended to the latest version, e.g. ``2.4-openbsd``.

### Notes

Memoized via :func:`functools.cache`, keyed on the *tmux_bin* argument
(``None`` is a distinct key from any explicit path), independently of
:func:`get_version_str`. The cache is sticky across ``PATH`` changes and
on-disk binary swaps when *tmux_bin* is ``None`` or the same path string --
call ``get_version.cache_clear()`` to invalidate. Tests that monkey-patch
:class:`tmux_cmd` should call ``cache_clear()`` before asserting
parsed-version behavior.

## Parameters

- `tmux_bin` (`str | None`): Path to tmux binary. If *None*, uses the system tmux from
:func:`shutil.which`.

## Returns

:class:`distutils.version.LooseVersion`
    tmux version according to *tmux_bin* if provided, otherwise the
    system tmux from :func:`shutil.which`
