Skip to content

Commit 8fbd76a

Browse files
Merge pull request #22 from Textualize/env-vars
Add TERM_PROGRAM(_VERSION) to textual-web.
2 parents 69b0691 + 20ba4ae commit 8fbd76a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/textual_web/app_session.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from datetime import timedelta
1515
from pathlib import Path
1616

17+
from importlib_metadata import version
1718

1819
import rich.repr
1920

@@ -132,6 +133,8 @@ async def open(self, width: int = 80, height: int = 24) -> None:
132133
environment["TEXTUAL_DRIVER"] = "textual.drivers.web_driver:WebDriver"
133134
environment["TEXTUAL_FPS"] = "60"
134135
environment["TEXTUAL_COLOR_SYSTEM"] = "truecolor"
136+
environment["TERM_PROGRAM"] = "textual-web"
137+
environment["TERM_PROGRAM_VERSION"] = version("textual-web")
135138
environment["COLUMNS"] = str(width)
136139
environment["ROWS"] = str(height)
137140
if self.devtools:

src/textual_web/terminal_session.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import annotations
22

3-
from dataclasses import dataclass, field
4-
from collections import deque
53
import asyncio
64
import array
75
import fcntl
@@ -11,7 +9,7 @@
119
import signal
1210
import termios
1311

14-
12+
from importlib_metadata import version
1513
import rich.repr
1614

1715
from .poller import Poller
@@ -20,7 +18,6 @@
2018

2119
log = logging.getLogger("textual-web")
2220

23-
2421
@rich.repr.auto
2522
class TerminalSession(Session):
2623
"""A session that manages a terminal."""
@@ -48,6 +45,8 @@ async def open(self, width: int = 80, height: int = 24) -> None:
4845
self.pid = pid
4946
self.master_fd = master_fd
5047
if pid == pty.CHILD:
48+
os.environ["TERM_PROGRAM"] = "textual-web"
49+
os.environ["TERM_PROGRAM_VERSION"] = version("textual-web")
5150
argv = [self.command]
5251
try:
5352
os.execlp(argv[0], *argv) ## Exits the app

0 commit comments

Comments
 (0)