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:booleanDefault:
false
- 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:booleanDefault:
false
- FFI function calls
- Data passed between layers
- Native function execution
OTUI_TRACE_FFI
Enable detailed tracing for the FFI bindings. Type:booleanDefault:
false
- Detailed call traces
- Performance metrics per call
- Memory allocation tracking
OTUI_SHOW_STATS
Show the debug overlay at startup. Type:booleanDefault:
false
- 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:booleanDefault:
false
OTUI_USE_ALTERNATE_SCREEN
Whether to use the alternate screen buffer. Type:booleanDefault:
true
- 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:booleanDefault:
true
Console Variables
OTUI_USE_CONSOLE
Whether to use the built-in console. When disabled, console output is not captured. Type:booleanDefault:
true
- You don’t need console.log capture
- You want better performance
- You’re using external logging
SHOW_CONSOLE
Show the console at startup. Type:booleanDefault:
false
OTUI_DUMP_CAPTURES
Dump captured console output when the renderer exits. Type:booleanDefault:
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:stringValues:
"true", "1", "false", "0"
"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:booleanDefault:
false
OPENTUI_FORCE_UNICODE
Force Mode 2026 Unicode support in terminal capabilities. Type:booleanDefault:
false
OPENTUI_FORCE_NOZWJ
Use no_zwj width method (Unicode without ZWJ joining). Type:booleanDefault:
false
OPENTUI_GRAPHICS
Enable Kitty graphics protocol detection. Type:booleanDefault:
true
Tree-sitter Variables
OTUI_TS_STYLE_WARN
Enable warnings for missing syntax styles. Type:stringDefault:
false
- Developing syntax highlighting themes
- Debugging missing style definitions
- Auditing theme coverage
OTUI_TREE_SITTER_WORKER_PATH
Path to the TreeSitter worker. Type:stringDefault:
""
XDG Base Directory Variables
XDG_CONFIG_HOME
Base directory for user-specific configuration files. Type:stringDefault:
~/.config
XDG_DATA_HOME
Base directory for user-specific data files. Type:stringDefault:
~/.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:
.env.local(highest priority).env.{NODE_ENV}.local.env.{NODE_ENV}.env
Environment Variable Precedence
-
Command line (highest priority)
-
Code
- Environment files (.env.local, .env)
-
Shell environment
- 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