fix: add terminfo capability guard to interactive.d scripts#27
Merged
Conversation
Prevent ZLE plugin failures (double echo, cursor garbling) when TERM is set to a value without a matching terminfo entry on the remote host (e.g. xterm-ghostty over SSH). Add dotfiles_term_capable() helper to lib.sh that checks both TERM value and actual terminfo availability via tput. Replace static TERM case guards in interactive.d scripts with this helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dotfiles_term_capable()helper tolib.shthat validates both TERM value and actual terminfo availability viatputcase TERM in ''|dumb)guards in 6 interactive.d scripts with the new helper80-prompt.shso fallback prompt is used when terminfo is unavailableProblem
When SSH-ing from Ghostty terminal (
TERM=xterm-ghostty) to a host without thexterm-ghosttyterminfo entry, ZLE plugins (p10k, autosuggestions, fast-syntax-highlighting) compute incorrect cursor positions becausetputfails and$COLUMNS=0. This causes progressive character garbling (e.g.,ls→lsls,claude→claudecllaauudclaude).Root Cause
The existing
case TERM in ''|dumb)guards only check for empty/dumb TERM values.xterm-ghosttypasses this guard (non-empty, non-dumb) but has no terminfo entry on the remote, causing all terminal capability queries to fail silently.Fix
dotfiles_term_capable()checks both conditions:dumbtput colsactually succeeds (terminfo is usable)Files Changed
modules/core/home/.config/dotfiles/lib.sh— newdotfiles_term_capable()helpermodules/prompt/home/.config/dotfiles/interactive.d/00-p10k-instant-prompt.zsh— add guard (had none)modules/core/home/.config/dotfiles/interactive.d/70-zsh-plugins.sh— upgrade guardmodules/prompt/home/.config/dotfiles/interactive.d/80-prompt.sh— guard p10k, keep fallbackmodules/prompt/home/.config/dotfiles/interactive.d/81-completion.zsh— upgrade guardmodules/prompt/home/.config/dotfiles/interactive.d/82-rich-plugins.zsh— upgrade guardmodules/prompt/home/.config/dotfiles/interactive.d/83-rich-fzf.sh— upgrade guardTest plan
xterm-ghosttyterminfo installed → full functionality (p10k, autosuggestions, syntax highlighting)ssh mac-mini— no character garbling, p10k prompt renders correctly, autosuggestions and syntax highlighting workTERM=xterm-ghostty tput cols→80,infocmp xterm-ghostty→ OKTERM=xterm-nonexistent zsh -c 'source ~/.zshrc; dotfiles_term_capable && echo pass || echo blocked'→blockedTERM=xterm-nonexistent zsh -l→ plugins skipped, fallback prompt worksdotfiles_term_capablereturns non-zero, all interactive.d guards fire, fallback prompt displayeddotfiles_term_capable→ pass, all plugins load normally🤖 Generated with Claude Code