From 4a039a45ec34c40cf999dacc28ed0696c3b79f68 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Jul 2023 21:49:25 +0530 Subject: [PATCH] Fix the save and clear ctrl+l zsh example --- kitty/options/definition.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 530d65cf8..ec328aa74 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -4026,14 +4026,19 @@ clearing of the current window: printf "\e[H\e[22J" } -For instance, using these functions, it is possible to remap :kbd:`Ctrl+L` to both scroll the current screen -contents into the scrollback buffer and clear the screen, instead of just -clearing the screen. For ZSH, in :file:`~/.zshrc` after the above functions, add: +For instance, using these escape codes, it is possible to remap :kbd:`Ctrl+L` +to both scroll the current screen contents into the scrollback buffer and clear +the screen, instead of just clearing the screen. For ZSH, in :file:`~/.zshrc`, add: .. code-block:: zsh - zle -N clear-screen-saving-contents-in-scrollback - bindkey '^l' clear-screen-saving-contents-in-scrollback + ctrl_l() { + builtin print -rn -- $'\e[H\e[22J' > "$TTY" + builtin zle .reset-prompt + builtin zle -R + } + zle -N ctrl_l + bindkey '^l' ctrl_l ''' )