Add a clear-screen bind function to clear the screen (#10044)

This can be bound like `bind \cl clear-screen`, and is, by default

In contrast to the current way it doesn't need the external `clear`
command that was always awkward.

Also it will clear the screen and first draw the old prompt to remove
flicker.
Then it will immediately trigger a repaint, so the prompt will be overwritten.
This commit is contained in:
Fabian Boehm
2023-10-08 11:41:30 +02:00
committed by GitHub
parent f7e7396c69
commit c4ca1a68d3
7 changed files with 36 additions and 3 deletions

View File

@@ -87,9 +87,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind --preset $argv \el __fish_list_current_token
bind --preset $argv \eo __fish_preview_current_file
bind --preset $argv \ew __fish_whatis_current_token
# ncurses > 6.0 sends a "delete scrollback" sequence along with clear.
# This string replace removes it.
bind --preset $argv \cl 'echo -n (clear | string replace \e\[3J ""); commandline -f repaint'
bind --preset $argv \cl clear-screen
bind --preset $argv \cc cancel-commandline
bind --preset $argv \cu backward-kill-line
bind --preset $argv \cw backward-kill-path-component