Summary
ghost-complete's shell integration causes two issues when used with zsh4humans + powerlevel10k:
- Ctrl+L hangs for ~5 seconds —
_gc_report_buffer on line-pre-redraw interferes with z4h's cursor position query
- Right prompt (RPROMPT) misaligned —
_gc_precmd OSC 133 output breaks powerlevel10k's prompt width calculation
Environment
- Terminal: Ghostty
- Shell: zsh with zsh4humans (v5) + powerlevel10k
- OS: macOS
Issue 1: Ctrl+L delay
Steps to reproduce
- Install zsh4humans
- Install ghost-complete (
ghost-complete install)
- Open a new terminal
- Press Ctrl+L
Expected: Screen clears instantly
Actual: Terminal hangs for ~5 seconds before clearing
Root cause
z4h's z4h-clear-screen-soft-* widgets call -z4h-get-cursor-pos, which:
- Sends
\e[6n (Device Status Report) to the terminal
- Reads the terminal's response (e.g.
\e[24;1R) from the TTY fd with read -srt 5 -d R
ghost-complete registers _gc_report_buffer on line-pre-redraw:
_gc_report_buffer() {
printf '\e]7770;%d;%s\a' "$CURSOR" "$BUFFER"
}
add-zle-hook-widget line-pre-redraw _gc_report_buffer
This hook fires during the redraw triggered by the clear-screen widget, writing \e]7770;... to the terminal at the same time z4h is trying to read the \e[6n response. The interleaved escape sequences corrupt the expected response pattern, causing z4h's read to retry and eventually time out after 5 seconds.
Workaround
Override z4h's clear-screen binding after z4h init:
bindkey '^L' clear-screen
Issue 2: Right prompt misalignment
Steps to reproduce
- Install zsh4humans (which uses powerlevel10k)
- Configure p10k with a 1-line prompt that has right prompt elements (e.g.
time)
- Install ghost-complete
- Open a new terminal
Expected: Right prompt elements (e.g. time) aligned to the right edge of the terminal
Actual: Right prompt floats in the middle, not pushed to the right edge
Root cause
_gc_precmd emits \e]133;A\a (OSC 133) before the prompt is drawn. This escape sequence has zero visible width, but it interferes with powerlevel10k's prompt width calculation for the gap between left and right prompt segments, causing RPROMPT to be mispositioned.
Note: z4h already provides its own OSC 133 shell integration via zstyle ':z4h:' term-shell-integration 'yes', so ghost-complete's markers are redundant when z4h is in use.
Suggested fixes
_gc_report_buffer could avoid writing to stdout during ZLE redraws triggered by other widgets, or debounce/defer the output to prevent interleaving with terminal queries.
_gc_precmd could detect when powerlevel10k or z4h shell integration is active and skip emitting duplicate OSC 133 markers.
Summary
ghost-complete's shell integration causes two issues when used with zsh4humans + powerlevel10k:
_gc_report_bufferonline-pre-redrawinterferes with z4h's cursor position query_gc_precmdOSC 133 output breaks powerlevel10k's prompt width calculationEnvironment
Issue 1: Ctrl+L delay
Steps to reproduce
ghost-complete install)Expected: Screen clears instantly
Actual: Terminal hangs for ~5 seconds before clearing
Root cause
z4h's
z4h-clear-screen-soft-*widgets call-z4h-get-cursor-pos, which:\e[6n(Device Status Report) to the terminal\e[24;1R) from the TTY fd withread -srt 5 -d Rghost-complete registers
_gc_report_bufferonline-pre-redraw:This hook fires during the redraw triggered by the clear-screen widget, writing
\e]7770;...to the terminal at the same time z4h is trying to read the\e[6nresponse. The interleaved escape sequences corrupt the expected response pattern, causing z4h's read to retry and eventually time out after 5 seconds.Workaround
Override z4h's clear-screen binding after
z4h init:bindkey '^L' clear-screenIssue 2: Right prompt misalignment
Steps to reproduce
time)Expected: Right prompt elements (e.g. time) aligned to the right edge of the terminal
Actual: Right prompt floats in the middle, not pushed to the right edge
Root cause
_gc_precmdemits\e]133;A\a(OSC 133) before the prompt is drawn. This escape sequence has zero visible width, but it interferes with powerlevel10k's prompt width calculation for the gap between left and right prompt segments, causing RPROMPT to be mispositioned.Note: z4h already provides its own OSC 133 shell integration via
zstyle ':z4h:' term-shell-integration 'yes', so ghost-complete's markers are redundant when z4h is in use.Suggested fixes
_gc_report_buffercould avoid writing to stdout during ZLE redraws triggered by other widgets, or debounce/defer the output to prevent interleaving with terminal queries._gc_precmdcould detect when powerlevel10k or z4h shell integration is active and skip emitting duplicate OSC 133 markers.