kitty @ set-colors wipes keyboard input buffer (zle)

Created on 5 Jun 2020  路  4Comments  路  Source: kovidgoyal/kitty

Happy for you to ignore this bug. I've got a workaround, and it's hard to describe and occurs in a specific context. But if you can think of an explanation off the top of your head, or better yet a fix, I'd appreciate it.

Describe the bug

When input into zsh (specifically zle, I think) is buffered rather than being input straight away, then kitty @ set-colors is run, this input seems to be discarded.

This results in commands and their output being discarded from the current window, including partially-typed commands.

See romkatv/powerlevel10k#665 for a further discussion here.

To Reproduce
Steps to reproduce the behavior:

  1. Use zsh plugin powerlevel10k's instant prompt feature
  2. Open a new kitty instance
  3. quickly type something before prompt initialisation finishes
  4. run kitty @ set-colours in the startup script.

Copied from the above issue:

Start zsh with the following .zshrc (uses zinit)

export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
if [[ -r "${XDG_CACHE_HOME}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

export PROMPT_COMMAND="kitty @ set-colors '/Users/user/.cache/kitty/kitty-themes/themes/Afterglow.conf'; $PROMPT_COMMAND"

# Enable using bash's PROMPT_COMMAND.
_prompt_command() { eval "$PROMPT_COMMAND" }
precmd_functions+=(_prompt_command)
sleep 1

ZINIT_DIR="/Users/user/.local/share/zinit/bin"
source "${ZINIT_DIR}/zinit.zsh"
# Theme with instant prompt support
zinit ice depth=1; zinit light romkatv/powerlevel10k
[ ! -f "$SCRIPT_DIR/plugins/p10k.zsh" ] || source "$SCRIPT_DIR/plugins/p10k.zsh"

Expected behavior

Typed text and outputs from entered commands should remain at the prompt

Actual behavior

Typed text and any quickly-entered commands, and their output, is replaced by a single blank prompt line (now nicely coloured).

Screenshots

I could probably capture a video/upload frames if that would help.

Enviroment details

Both linux and OSX

Output of kitty --debug-config

Additional context

Reproduced with minimial config: shell zsh -l

bug

All 4 comments

kitty @ will by default write to the tty and get responses from the tty
as well. That will mess up zsh since I suspect it wants exclusive
control of the tty during prompt drawing. Use a socket for remote
control instead and you should be fine.

Thanks for the response. romkatv suggested doing <$TTY >$TTY kitty @ set-colors but that still didn't work. Does that fit with what you've just described?

kitty uses /dev/tty so redirecting $TTY is not going to have any effect.

Thanks for the answer!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Askannz picture Askannz  路  3Comments

hdriqi picture hdriqi  路  3Comments

drandreaskrueger picture drandreaskrueger  路  4Comments

skosch picture skosch  路  3Comments

mihaicristiantanase picture mihaicristiantanase  路  3Comments