Fix Ctrl-W/Y in xonsh

This commit is contained in:
2022-05-12 21:46:23 -07:00
parent 034ef10c09
commit 727b511cf8
3 changed files with 18 additions and 3 deletions

16
xonsh/bindings.xsh Normal file
View File

@@ -0,0 +1,16 @@
from prompt_toolkit.key_binding.bindings.named_commands import get_by_name
from prompt_toolkit.keys import Keys
@events.on_ptk_create
def custom_keybindings(bindings, **kw):
@bindings.add(Keys.ControlW)
def delete_word(event):
get_by_name("backward-kill-word").call(event)
@bindings.add(Keys.ControlX, Keys.ControlA)
def select_all(event):
buffer = event.current_buffer
buffer.cursor_position = 0
buffer.start_selection()
buffer.selection_state.enter_shift_mode()
buffer.cursor_position = len(buffer.text)