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: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force

<!-- Maintainers, insert changes / features for the next release here -->

- `tmuxp shell` now detects current `server` via `TMUX` (#854)

## tmuxp 1.21.0 (2022-12-27)

*Maintenance only, no bug fixes or features*
Expand Down
12 changes: 12 additions & 0 deletions src/tmuxp/cli/shell.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import os
import pathlib
import typing as t

from libtmux.server import Server
Expand Down Expand Up @@ -140,6 +141,17 @@ def command_shell(
- :attr:`libtmux.Server.attached_sessions`, :attr:`libtmux.Session.attached_window`,
:attr:`libtmux.Window.attached_pane`
"""
# If inside a server, detect socket_path
env_tmux = os.getenv("TMUX")
if env_tmux is not None and isinstance(env_tmux, str):
env_socket_path = pathlib.Path(env_tmux.split(",")[0])
if (
env_socket_path.exists()
and args.socket_path is None
and args.socket_name is None
):
args.socket_path = str(env_socket_path)

server = Server(socket_name=args.socket_name, socket_path=args.socket_path)

server.raise_if_dead()
Expand Down