From 39dd9efd5dfa1fb36281f9f97b753152af82095f Mon Sep 17 00:00:00 2001 From: kapobajza <33549969+kapobajza@users.noreply.github.com> Date: Thu, 15 May 2025 15:08:20 +0200 Subject: [PATCH] fix(shell): Paste not working in zsh shell integration (#512) Fixes https://github.com/alexpasmantier/television/issues/393 --- television/utils/shell/completion.zsh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/television/utils/shell/completion.zsh b/television/utils/shell/completion.zsh index ad6c7ae..96cf25a 100644 --- a/television/utils/shell/completion.zsh +++ b/television/utils/shell/completion.zsh @@ -1,7 +1,23 @@ +_disable_bracketed_paste() { + # Check if bracketed paste is defined, for compatibility with older versions + if [[ -n $zle_bracketed_paste ]]; then + print -nr ${zle_bracketed_paste[2]} >/dev/tty + fi +} + +_enable_bracketed_paste() { + # Check if bracketed paste is defined, for compatibility with older versions + if [[ -n $zle_bracketed_paste ]]; then + print -nr ${zle_bracketed_paste[1]} >/dev/tty + fi +} + _tv_smart_autocomplete() { emulate -L zsh zle -I + _disable_bracketed_paste + # prefix (lhs of cursor) local current_prompt current_prompt=$LBUFFER @@ -24,12 +40,16 @@ _tv_smart_autocomplete() { # (i.e. run the command without having to press enter twice) # zle accept-line fi + + _enable_bracketed_paste } _tv_shell_history() { emulate -L zsh zle -I + _disable_bracketed_paste + local current_prompt current_prompt=$LBUFFER @@ -46,6 +66,8 @@ _tv_shell_history() { # (i.e. run the command without having to press enter twice) # zle accept-line fi + + _enable_bracketed_paste }