Skip to content

ZSH widget: ANSI escape codes displayed literally instead of coloring text #81

@noahgift

Description

@noahgift

Bug Description

The ZSH widget displays raw ANSI escape codes instead of rendering colored text.

Observed Behavior

When typing in the shell, the suggestion appears with literal escape sequences:

➜  /tmp claude --dangerously-skip-permissions --resume^[[90m ^[[0m

The ^[[90m (gray) and ^[[0m (reset) codes are shown as text instead of being interpreted.

Expected Behavior

The suggestion text should appear in gray without visible escape codes.

Root Cause

In the zsh-widget output, the code uses:

POSTDISPLAY=$'\e[90m'"$POSTDISPLAY"$'\e[0m'

ZSH's POSTDISPLAY does not interpret ANSI escape sequences in all terminal/configuration contexts.

Suggested Fix

Use ZSH prompt expansion syntax instead of ANSI escapes:

POSTDISPLAY="%F{240}${POSTDISPLAY}%f"

Or use zle region highlighting:

region_highlight=("$#BUFFER $((#BUFFER + #POSTDISPLAY)) fg=gray")

Environment

  • aprender-shell 0.1.0
  • ZSH with oh-my-zsh (Powerlevel10k theme suspected)
  • Linux

Reproduction

  1. cargo install aprender-shell
  2. aprender-shell train
  3. aprender-shell zsh-widget >> ~/.zshrc
  4. source ~/.zshrc
  5. Start typing a command

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions