Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tmux detection #104

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion rplugin/python3/magma/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,17 @@ def serialize_gr_command(self, **cmd): # type: ignore
w(payload)
w(b"\033\\")
ans = b"".join(ans) # type: ignore
if "tmux" in os.environ["TERM"]:
# Mangling the escape codes to make them work inside tmux
inside_tmux = (
any(os.environ.get("TMUX", ""))
or
# Only for tmux >= 3.2
"tmux" in os.environ.get("TERM_PROGRAM", "")
or
# Not reliable, TERM can be set to screen-256color, xterm-kitty, etc.
"tmux" in os.environ.get("TERM", "")
)
if inside_tmux:
ans = b"\033Ptmux;" + ans.replace(b"\033", b"\033\033") + b"\033\\" # type: ignore
return ans

Expand Down