From dfc7524100bf5233bcd272904bad43de2eb0e963 Mon Sep 17 00:00:00 2001 From: Andy Kipp Date: Sun, 18 Feb 2024 20:52:10 +0100 Subject: [PATCH] Update README.md --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 86e47e1..8881111 100644 --- a/README.md +++ b/README.md @@ -915,12 +915,17 @@ def custom_keybindings(bindings, **kw): # Press F3 to insert the grep command @bindings.add(Keys.F3) # or for Mac try `@bindings.add("c-k") # control+k` - def say_hi(event): + def add_grep(event): event.current_buffer.insert_text('| grep -i ') + + # Clear line by pressing `Escape` key + @bindings.add("escape") + def clear_line(event): + event.current_buffer.delete_before_cursor(1000) ``` -See also: [More about key bindings](https://python-prompt-toolkit.readthedocs.io/en/master/pages/advanced_topics/key_bindings.html). +See also: [more about key bindings](https://python-prompt-toolkit.readthedocs.io/en/master/pages/advanced_topics/key_bindings.html), [event.current_buffer](https://python-prompt-toolkit.readthedocs.io/en/stable/pages/reference.html#prompt_toolkit.buffer.Buffer). # [Xontrib](https://xon.sh/tutorial_xontrib.html) - extension or plugin for xonsh