Environment Variables
The Terminal injects environment variables into every terminal session. These enable CLI tools and AI assistants to detect and interact with The Terminal’s features.
Variables
Section titled “Variables”THE_TERMINAL_ID
Section titled “THE_TERMINAL_ID”A unique identifier for the current Terminal instance.
echo $THE_TERMINAL_ID# e.g., "terminal-a1b2c3d4"Use this to distinguish between multiple Terminal windows or to associate activity with a specific instance.
THE_TERMINAL_DEVTOOLS_PORT
Section titled “THE_TERMINAL_DEVTOOLS_PORT”The port number where the DevTools HTTP API is listening.
echo $THE_TERMINAL_DEVTOOLS_PORT# e.g., "9876"Gee-Code uses this to connect to the browser panel.
THE_TERMINAL_DEVTOOLS_URL
Section titled “THE_TERMINAL_DEVTOOLS_URL”The full URL for the DevTools API.
echo $THE_TERMINAL_DEVTOOLS_URL# e.g., "http://localhost:9876"Equivalent to http://localhost:$THE_TERMINAL_DEVTOOLS_PORT.
TERM_BACKGROUND
Section titled “TERM_BACKGROUND”The background color mode of the terminal, for tools that adapt their output to the theme.
echo $TERM_BACKGROUND# "dark" or "light"DevTools Config File
Section titled “DevTools Config File”In addition to environment variables, The Terminal writes connection details to a file:
~/.the-terminal/devtools.json{ "port": 9876, "url": "http://localhost:9876"}This file is used by Gee-Code and other tools that need to discover the DevTools API without being launched from within The Terminal.
Using These Variables
Section titled “Using These Variables”In Shell Scripts
Section titled “In Shell Scripts”if [ -n "$THE_TERMINAL_DEVTOOLS_URL" ]; then echo "Running inside The Terminal" # Use DevTools API for enhanced outputelse echo "Running in a standard terminal"fiIn Node.js
Section titled “In Node.js”const devtoolsUrl = process.env.THE_TERMINAL_DEVTOOLS_URL;if (devtoolsUrl) { // Send rich output to The Terminal's Canvas}In Python
Section titled “In Python”import osdevtools_url = os.environ.get('THE_TERMINAL_DEVTOOLS_URL')if devtools_url: # Integrate with The Terminal's DevTools APINext Steps
Section titled “Next Steps”- DevTools API — what you can do with the API
- System Requirements — platform details