dx provides sophisticated command execution capabilities with full terminal emulation, interactive input, and safe process management.

Execution Modes

Internal Mode

Commands run inside dx TUI with full output capture and control

External Mode

Commands run in your shell, then return to dx interface

Internal Mode (Default)

[[items]]
name = "Build Project"
cmd = "cargo build --release"
external = false  # Default behavior
  • Full PTY integration for terminal apps
  • Real-time ANSI color output
  • Interactive stdin support
  • Process control with confirmations

External Mode

[[items]]
name = "Open Editor"
cmd = "code ."
external = true   # Drops to shell temporarily
  • Runs in your native shell environment
  • Full TTY access for complex applications
  • Automatic return to dx interface
  • Pause prompt for short-running commands

Real-Time Output Features

Visual Indicators

  • Animated spinners during command execution
  • Live timers showing execution duration
  • Process status with colored exit codes
  • Progress feedback for long-running tasks

ANSI Support

dx preserves full ANSI color sequences and terminal formatting:
# Colors, bold, italic, underline all preserved
echo -e "\033[31mError:\033[0m \033[1mBold text\033[0m"

Interactive Input

Standard Input
feature
Full stdin support for interactive commands like prompts, passwords, and user input
Terminal Emulation
feature
PTY integration automatically detects and handles TUI applications
Signal Handling
feature
Proper forwarding of Ctrl+C, Ctrl+Z, and other terminal signals

Process Control & Safety

Safe Kill Confirmation

When you press Ctrl+C during command execution:
  1. dx shows a confirmation modal
  2. Press Enter to kill the process
  3. Press Esc to cancel and continue

Exit Status Handling

Commands complete with clear status indicators:
  • 🟢 Success - Exit code 0 with green indicator
  • 🔴 Error - Non-zero exit with red indicator
  • 🟡 Terminated - Process killed with yellow indicator

Advanced Features

Environment Variables

Commands inherit your shell environment plus dx-specific variables:
# Available in all commands
echo "Menu: $DX_MENU_NAME"
echo "Item: $DX_ITEM_NAME"  

Working Directory

Commands execute in the directory where dx was launched, with full access to:
  • Project files and directories
  • Git repository context
  • Local configurations

Output Capture

All command output is captured and can be:
  • Scrolled through with full history
  • Searched and filtered
  • Exported or shared via recordings
Use external = true for commands that need full shell features like job control, complex piping, or shell-specific syntax.
Interactive password prompts work best with external = false mode for security and proper terminal handling.