# **AI Context Prompt Extension for Terminal Output Formatting with Heredocs and Piping** When generating Bash scripts for terminal output, where heredocs are used to create formatted text for terminal utilities such as **charmbracelet/gum** or **charmbracelet/glow**, ensure the following conventions are adhered to: ### 1. **Terminal-Specific Heredoc Handling for Pipe Output** - **Literal (Quoted) Heredoc (`<<'EOF'`)**: - This heredoc syntax **prevents variable expansion** by Bash and **should be used exclusively for output** that is intended to be **literally rendered** by terminal tools like `gum` or `glow`. - Variables and other dynamic content, such as `$STATUS` or `$PATH`, use `Indented Tab Standard (<<-EOF) for Terminal Output` below. - The output will be passed through the pipeline to utilities like `charmbracelet/gum` or `charmbracelet/glow` for display, but **no Bash substitution** (e.g., variable expansion or command substitution) should occur. Example: ```bash MESSAGE=$( cat <<-'EOF' # HEADER System Report ## SUBHEADER System Report Status: {{status}} Note: $PATH will not be expanded by Bash here. It will be rendered literally. EOF ) # Echo the message variable content and pipe it to glow (should render Markdown properly) echo "$MESSAGE" | glow - ``` - This ensures that tools like `gum` will receive the **raw content** without any Bash variable substitution. ### 2. **Indented Tab Standard (`<<-EOF`) for Terminal Output** - Use `<<-EOF` when outputting **indented content** to terminal tools but where leading **tabs** should be stripped by the shell. - This is especially useful for ensuring **clean, indented formatting** in the terminal output without the need for excessive formatting in the source code. - The leading tabs will be removed by Bash, but the rest of the heredoc’s content should be piped into terminal utilities for **direct rendering**. Example: ```bash status="Online" # Store heredoc output into a variable and ensure it's a string MESSAGE=$( cat <<-EOF # HEADER System Report ## SUBHEADER System Report - Status: ${status} * This is indented text that will be rendered in the terminal. EOF ) # Echo the message variable content and pipe it to glow (should render Markdown properly) echo "$MESSAGE" | glow - ``` - This ensures that terminal output remains **visually structured** (indented) while adhering to the need for **literal tab handling** when passed through tools like `glow` or `gum`. ### 3. **Strict DSL Enforcement for Terminal Output** - **DSL Control**: Since your DSL is responsible for ensuring correctness, it will **strictly enforce heredoc behavior** for terminal-based outputs, maintaining that: - **Heredocs with `<<'EOF'`** should always **pass literal, unmodified content** (including variable-like placeholders like `{{status}}`) into tools like `gum` or `glow` without Bash interpreting them. - **Heredocs with `<<-EOF`** will be **tab-stripped** by Bash but remain **visually consistent** in output, keeping the layout clean for terminal utilities that interpret and display that content. ### 4. **Clear Division of Logic and Output Rendering** - The **DSL must isolate dynamic content** (variables, logic, etc.) from the static content being rendered into the terminal. Variables must be passed through to terminal utilities like `gum` or `glow` for **post-processing** and final display, not handled by Bash at runtime. - This ensures that the script output remains **clean and predictable**, with Bash doing as little as possible beyond piping content to terminal utilities. ### 5. **Summary of Heredoc Types for Terminal Output Formatting** | Feature | Syntax | Behavior | DSL/Parser Impact | | ------------------------ | ---------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------- | | **Standard** | `<