Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ windows:
- **Doctest format**: Use narrative descriptions with blank lines between sections
- **Complex examples**: Move to `tests/examples/<path>/test_<example>.py`
- **Minimum Python**: 3.9+ (as per README)
- **Minimum tmux**: 1.8+ (as per README)
- **Minimum tmux**: 3.2+ (as per README)
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _Future release notes will be placed here_

### Breaking changes

#### Minimum tmux version bumped to 3.2+ (#992)
#### Minimum tmux version bumped to 3.2+ (#992, #993)

tmux versions below 3.2a are now disabled (via libtmux v0.49.0).

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ See donation options at <https://tony.sh/support.html>.

# Project details

- tmux support: 1.8+
- tmux support: 3.2+
- python support: >= 3.10, pypy, pypy3
- Source: <https://github.com/tmux-python/tmuxp>
- Docs: <https://tmuxp.git-pull.com>
Expand Down
4 changes: 2 additions & 2 deletions docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ well tested and adopted.

### Missing

**Version support** tmuxp only supports `tmux >= 1.8`. Teamocil and
**Version support** tmuxp only supports `tmux >= 3.2`. Teamocil and
tmuxinator may have support for earlier versions.

### Differences
Expand All @@ -64,7 +64,7 @@ format [^id4]. See {ref}`cli-freeze`.

**JSON config** JSON config support. See {ref}`Examples`.

**ORM-based API** via [libtmux] - Utilizes tmux >= 1.8's unique ID's for
**ORM-based API** via [libtmux] - Utilizes tmux's unique IDs for
panes, windows and sessions to create an object relational view of the tmux
{class}`~libtmux.Server`, its {class}`~libtmux.Session`,
{class}`~libtmux.Window`, and {class}`~libtmux.Pane`.
Expand Down
5 changes: 2 additions & 3 deletions docs/about_tmux.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ For the freshest results on how to get tmux installed on your system,
"How to install tmux on \<my distro>" will do, as directions change and
are slightly different between distributions.

This documentation is written for version **1.8**. It's important that
you have the latest stable release of tmux. The latest stable version is
viewable on the [tmux homepage](http://tmux.sourceforge.net/).
tmuxp requires tmux **3.2 or newer**. The latest stable version is
viewable on the [tmux homepage](https://github.com/tmux/tmux).

**Mac OS X** users may install the latest stable version of tmux
through [MacPorts](http://www.macports.org/),
Expand Down
3 changes: 1 addition & 2 deletions docs/configuration/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ tmuxp will set session, window and pane environment variables.

```{note}
Setting environment variables for windows and panes requires tmuxp 1.19 or
newer and tmux 3.0 or newer.
Setting environment variables for windows and panes requires tmuxp 1.19 or newer.
```

````{tab} YAML
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Installation

Ensure you have at least tmux **>= 1.8** and python **>= 3.7**.
Ensure you have at least tmux **>= 3.2** and python **>= 3.9**.

```console
$ pip install --user tmuxp
Expand Down
21 changes: 0 additions & 21 deletions src/tmuxp/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,27 +275,6 @@ def load_workspace(
prompt to cleanup (``$ tmux kill-session``) the session on the user's
behalf. An exception raised during this process means it's not easy to
predict how broken the session is.

.. versionchanged:: tmux 2.6+

In tmux 2.6, the way layout and proportion's work when interfacing
with tmux in a detached state (outside of a client) changed. Since
tmuxp builds workspaces in a detached state, the WorkspaceBuilder isn't
able to rely on functionality requiring awarness of session geometry,
e.g. ``set-layout``.

Thankfully, tmux is able to defer commands to run after the user
performs certain actions, such as loading a client via
``attach-session`` or ``switch-client``.

Upon client switch, ``client-session-changed`` is triggered [1]_.

References
----------
.. [1] cmd-switch-client.c hook. GitHub repo for tmux.

https://github.com/tmux/tmux/blob/2.6/cmd-switch-client.c#L132.
Accessed April 8th, 2018.
"""
# get the canonical path, eliminating any symlinks
if isinstance(workspace_file, (str, os.PathLike)):
Expand Down
4 changes: 2 additions & 2 deletions src/tmuxp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from .__about__ import __version__
from .exc import TmuxpPluginException

#: Minimum version of tmux required to run libtmux
TMUX_MIN_VERSION = "1.8"
#: Minimum version of tmux required to run tmuxp
TMUX_MIN_VERSION = "3.2"

#: Most recent version of tmux supported
TMUX_MAX_VERSION = None
Expand Down
35 changes: 1 addition & 34 deletions src/tmuxp/workspace/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import typing as t

from libtmux._internal.query_list import ObjectDoesNotExist
from libtmux.common import has_gte_version, has_lt_version
from libtmux.pane import Pane
from libtmux.server import Server
from libtmux.session import Session
Expand Down Expand Up @@ -253,10 +252,7 @@ def build(self, session: Session | None = None, append: bool = False) -> None:
"start_directory"
]

if (
has_gte_version("2.6")
and os.getenv("TMUXP_DETECT_TERMINAL_SIZE", "1") == "1"
):
if os.getenv("TMUXP_DETECT_TERMINAL_SIZE", "1") == "1":
terminal_size = shutil.get_terminal_size(
fallback=(get_default_columns(), get_default_rows()),
)
Expand Down Expand Up @@ -406,25 +402,6 @@ def iter_create_windows(
pass

environment = panes[0].get("environment", window_config.get("environment"))
if environment and has_lt_version("3.0"):
# Falling back to use the environment of the first pane for the window
# creation is nice but yields misleading error messages.
pane_env = panes[0].get("environment")
win_env = window_config.get("environment")
if pane_env and win_env:
target = "panes and windows"
elif pane_env:
target = "panes"
else:
target = "windows"
logger.warning(
(
"Cannot set environment for new %s. "
"You need tmux 3.0 or newer for this."
),
target,
)
environment = None

window = session.new_window(
window_name=window_name,
Expand Down Expand Up @@ -513,16 +490,6 @@ def get_pane_shell(
"environment",
window_config.get("environment"),
)
if environment and has_lt_version("3.0"):
# Just issue a warning when the environment comes from the pane
# configuration as a warning for the window was already issued when
# the window was created.
if pane_config.get("environment"):
logger.warning(
"Cannot set environment for new panes. "
"You need tmux 3.0 or newer for this.",
)
environment = None

assert pane is not None

Expand Down
5 changes: 0 additions & 5 deletions tests/cli/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import libtmux
import pytest
from libtmux.common import has_lt_version
from libtmux.server import Server
from libtmux.session import Session

Expand Down Expand Up @@ -96,10 +95,6 @@ def test_load_workspace_named_session(
assert session.name == "tmuxp-new"


@pytest.mark.skipif(
has_lt_version("2.1"),
reason="exact session name matches only tmux >= 2.1",
)
def test_load_workspace_name_match_regression_252(
tmp_path: pathlib.Path,
server: Server,
Expand Down
72 changes: 2 additions & 70 deletions tests/workspace/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import libtmux
import pytest
from libtmux._internal.query_list import ObjectDoesNotExist
from libtmux.common import has_gte_version, has_lt_version
from libtmux.exc import LibTmuxException
from libtmux.pane import Pane
from libtmux.session import Session
Expand Down Expand Up @@ -296,8 +295,7 @@ def test_window_options(
)
workspace = loader.expand(workspace)

if has_gte_version("2.3"):
workspace["windows"][0]["options"]["pane-border-format"] = " #P "
workspace["windows"][0]["options"]["pane-border-format"] = " #P "

builder = WorkspaceBuilder(session_config=workspace, server=session.server)

Expand All @@ -310,8 +308,7 @@ def test_window_options(
assert len(session.windows) == window_count
assert isinstance(w, Window)
assert w.show_window_option("main-pane-height") == 5
if has_gte_version("2.3"):
assert w.show_window_option("pane-border-format") == " #P "
assert w.show_window_option("pane-border-format") == " #P "

assert len(session.windows) == window_count
window_count += 1
Expand Down Expand Up @@ -386,10 +383,6 @@ def f(w: Window) -> bool:
assert w.name != "top"


@pytest.mark.skipif(
has_lt_version("3.0"),
reason="needs -e flag for new-window and split-window introduced in tmux 3.0",
)
def test_environment_variables(
session: Session,
) -> None:
Expand Down Expand Up @@ -431,58 +424,6 @@ def test_environment_variables(
assert pane.capture_pane()[1] == "PANE"


@pytest.mark.skipif(
has_gte_version("3.0"),
reason="warnings are not needed for tmux >= 3.0",
)
def test_environment_variables_warns_prior_to_tmux_3_0(
session: Session,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Warns when environmental variables cannot be set prior to tmux 3.0."""
workspace = ConfigReader._from_file(
test_utils.get_workspace_file("workspace/builder/environment_vars.yaml"),
)
workspace = loader.expand(workspace)

builder = WorkspaceBuilder(session_config=workspace, server=session.server)
builder.build(session)

# environment on sessions should work as this is done using set-environment
# on the session itself
assert session.getenv("FOO") == "SESSION"
assert session.getenv("PATH") == "/tmp"

assert (
sum(
1
for record in caplog.records
if "Cannot set environment for new windows." in record.message
)
# From window_overrides and both_overrides, but not
# both_overrides_in_first_pane.
== 2
), "Warning on creating windows missing"
assert (
sum(
1
for record in caplog.records
if "Cannot set environment for new panes." in record.message
)
# From pane_overrides and both_overrides, but not both_overrides_in_first_pane.
== 2
), "Warning on creating panes missing"
assert (
sum(
1
for record in caplog.records
if "Cannot set environment for new panes and windows." in record.message
)
# From both_overrides_in_first_pane.
== 1
)


def test_automatic_rename_option(
server: Server,
monkeypatch: pytest.MonkeyPatch,
Expand Down Expand Up @@ -656,10 +597,6 @@ def f(path: str, p: Pane) -> bool:
assert retry_until(f_)


@pytest.mark.skipif(
has_lt_version("3.2a"),
reason="needs format introduced in tmux >= 3.2a",
)
def test_start_directory_sets_session_path(server: Server) -> None:
"""Test start_directory setting path in session_path."""
workspace = ConfigReader._from_file(
Expand Down Expand Up @@ -1442,10 +1379,6 @@ def f(path: str, p: Pane) -> bool:
assert retry_until(f_)


@pytest.mark.skipif(
has_lt_version("2.9"),
reason="needs option introduced in tmux >= 2.9",
)
def test_layout_main_horizontal(session: Session) -> None:
"""Test that tmux's main-horizontal layout is used when specified."""
yaml_workspace = test_utils.get_workspace_file("workspace/builder/three_pane.yaml")
Expand Down Expand Up @@ -1523,7 +1456,6 @@ class DefaultSizeNamespaceFixture(t.NamedTuple):
DEFAULT_SIZE_FIXTURES,
ids=[f.test_id for f in DEFAULT_SIZE_FIXTURES],
)
@pytest.mark.skipif(has_lt_version("2.9"), reason="default-size only applies there")
def test_issue_800_default_size_many_windows(
server: Server,
monkeypatch: pytest.MonkeyPatch,
Expand Down