Skip to main content
OpenTUI can be configured using environment variables to control rendering behavior, debugging features, and terminal capabilities.

Setting Environment Variables

In Shell

In Code

In .env File

Bun automatically loads .env files - no need for dotenv package.

Debugging Variables

OTUI_DEBUG

Enable debug mode to capture all raw input for debugging purposes. Type: boolean
Default: false
When enabled:
  • Captures raw terminal input
  • Logs input sequences
  • Useful for debugging keyboard/mouse issues

OTUI_DEBUG_FFI

Enable debug logging for the FFI bindings between TypeScript and Zig. Type: boolean
Default: false
Logs:
  • FFI function calls
  • Data passed between layers
  • Native function execution

OTUI_TRACE_FFI

Enable detailed tracing for the FFI bindings. Type: boolean
Default: false
Provides:
  • Detailed call traces
  • Performance metrics per call
  • Memory allocation tracking

OTUI_SHOW_STATS

Show the debug overlay at startup. Type: boolean
Default: false
Displays:
  • FPS counter
  • Frame time statistics
  • Memory usage
  • Render buffer info

Rendering Variables

OTUI_NO_NATIVE_RENDER

Disable native rendering. Useful for debugging without actual terminal output. Type: boolean
Default: false
This will not output any ANSI sequences to the terminal. Only use for debugging.

OTUI_USE_ALTERNATE_SCREEN

Whether to use the alternate screen buffer. Type: boolean
Default: true
When disabled:
  • Renders in main screen buffer
  • Content persists after exit
  • May interfere with terminal scrollback

OTUI_OVERRIDE_STDOUT

Override the stdout stream. Useful for debugging. Type: boolean
Default: true

Console Variables

OTUI_USE_CONSOLE

Whether to use the built-in console. When disabled, console output is not captured. Type: boolean
Default: true
Disable if:
  • You don’t need console.log capture
  • You want better performance
  • You’re using external logging

SHOW_CONSOLE

Show the console at startup. Type: boolean
Default: false

OTUI_DUMP_CAPTURES

Dump captured console output when the renderer exits. Type: boolean
Default: false

Terminal Compatibility Variables

OPENTUI_FORCE_EXPLICIT_WIDTH

Force explicit width capability to true or false. Use this to fix artifacts on older terminals. Type: string
Values: "true", "1", "false", "0"
Set to false or 0 on GNOME Terminal, Konsole, or xterm to prevent “66” artifacts.
When set to "false" or "0":
  • Prevents OSC 66 detection queries
  • Disables explicit width feature
  • Falls back to standard width calculation
  • No visual artifacts on unsupported terminals

OPENTUI_FORCE_WCWIDTH

Use wcwidth for character width calculations. Type: boolean
Default: false

OPENTUI_FORCE_UNICODE

Force Mode 2026 Unicode support in terminal capabilities. Type: boolean
Default: false

OPENTUI_FORCE_NOZWJ

Use no_zwj width method (Unicode without ZWJ joining). Type: boolean
Default: false

OPENTUI_GRAPHICS

Enable Kitty graphics protocol detection. Type: boolean
Default: true

Tree-sitter Variables

OTUI_TS_STYLE_WARN

Enable warnings for missing syntax styles. Type: string
Default: false
Useful when:
  • Developing syntax highlighting themes
  • Debugging missing style definitions
  • Auditing theme coverage

OTUI_TREE_SITTER_WORKER_PATH

Path to the TreeSitter worker. Type: string
Default: ""

XDG Base Directory Variables

XDG_CONFIG_HOME

Base directory for user-specific configuration files. Type: string
Default: ~/.config

XDG_DATA_HOME

Base directory for user-specific data files. Type: string
Default: ~/.local/share

Common Configuration Scenarios

Development Mode

Production Mode

Performance Testing

Debugging FFI Issues

Legacy Terminal Compatibility

Terminal-Specific Configurations

GNOME Terminal

Kitty / Ghostty / WezTerm

Windows Terminal

tmux / screen

Loading Environment Files

Bun automatically loads .env files in this order:
  1. .env.local (highest priority)
  2. .env.{NODE_ENV}.local
  3. .env.{NODE_ENV}
  4. .env
Example project structure:

Environment Variable Precedence

  1. Command line (highest priority)
  2. Code
  3. Environment files (.env.local, .env)
  4. Shell environment
  5. Default values (lowest priority)

Troubleshooting

Artifacts on Screen

If you see weird characters like “66” on screen:

Performance Issues

Disable console capture:

Missing Console Output

Enable console:

Debugging Not Working

Enable debug features:

Next Steps

Performance

Optimize your application

Native Zig Core

Understand the architecture