mirror of
https://github.com/open-webui/open-terminal.git
synced 2026-07-09 16:09:14 +00:00
feat: configurable TERM env var for terminal color support
Terminal sessions now set the TERM environment variable (default xterm-256color) so programs emit ANSI color codes. Configurable via OPEN_TERMINAL_TERM environment variable or 'term' in config.toml.
This commit is contained in:
parent
4d896916bd
commit
87b0dcfba5
4 changed files with 21 additions and 6 deletions
|
|
@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
|
||||
## [0.8.2] - 2026-03-02
|
||||
|
||||
### Added
|
||||
|
||||
- 🎨 **Terminal color support** — terminal sessions now set the `TERM` environment variable (default `xterm-256color`) so programs emit ANSI color codes. Configurable via `OPEN_TERMINAL_TERM` environment variable or `term` in config.toml.
|
||||
|
||||
## [0.8.1] - 2026-03-02
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -70,3 +70,8 @@ ENABLE_TERMINAL = os.environ.get(
|
|||
"OPEN_TERMINAL_ENABLE_TERMINAL",
|
||||
str(config.get("enable_terminal", True)),
|
||||
).lower() not in ("false", "0", "no")
|
||||
|
||||
TERMINAL_TERM = os.environ.get(
|
||||
"OPEN_TERMINAL_TERM",
|
||||
config.get("term", "xterm-256color"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import asyncio
|
||||
|
||||
from importlib.metadata import version as _pkg_version
|
||||
import fnmatch
|
||||
import json
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
|||
from pydantic import BaseModel, Field
|
||||
from pypdf import PdfReader
|
||||
|
||||
from open_terminal.env import API_KEY, BINARY_FILE_MIME_PREFIXES, CORS_ALLOWED_ORIGINS, ENABLE_TERMINAL, LOG_DIR, MAX_TERMINAL_SESSIONS
|
||||
from open_terminal.env import API_KEY, BINARY_FILE_MIME_PREFIXES, CORS_ALLOWED_ORIGINS, ENABLE_TERMINAL, LOG_DIR, MAX_TERMINAL_SESSIONS, TERMINAL_TERM
|
||||
from open_terminal.runner import PipeRunner, ProcessRunner, create_runner
|
||||
|
||||
try:
|
||||
|
|
@ -69,7 +69,7 @@ async def verify_api_key(
|
|||
app = FastAPI(
|
||||
title="Open Terminal",
|
||||
description="A remote terminal API.",
|
||||
version="0.8.1",
|
||||
version=_pkg_version("open-terminal"),
|
||||
)
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
|
@ -1223,13 +1223,15 @@ if ENABLE_TERMINAL:
|
|||
fcntl.ioctl(slave_fd, termios.TIOCSWINSZ, struct.pack("HHHH", 24, 80, 0, 0))
|
||||
|
||||
shell = os.environ.get("SHELL", "/bin/sh")
|
||||
spawn_env = os.environ.copy()
|
||||
spawn_env.setdefault("TERM", TERMINAL_TERM)
|
||||
process = subprocess.Popen(
|
||||
[shell],
|
||||
stdin=slave_fd,
|
||||
stdout=slave_fd,
|
||||
stderr=slave_fd,
|
||||
cwd=os.getcwd(),
|
||||
env=os.environ.copy(),
|
||||
env=spawn_env,
|
||||
start_new_session=True,
|
||||
)
|
||||
except Exception:
|
||||
|
|
@ -1252,10 +1254,12 @@ if ENABLE_TERMINAL:
|
|||
|
||||
else: # winpty
|
||||
shell = os.environ.get("COMSPEC", "cmd.exe")
|
||||
spawn_env = os.environ.copy()
|
||||
spawn_env.setdefault("TERM", TERMINAL_TERM)
|
||||
pty_proc = _WinPtyProcess.spawn(
|
||||
[shell],
|
||||
cwd=os.getcwd(),
|
||||
env=os.environ.copy(),
|
||||
env=spawn_env,
|
||||
dimensions=(24, 80),
|
||||
)
|
||||
_terminal_sessions[session_id] = {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "open-terminal"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
description = "A remote terminal API."
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue