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

View File

@@ -25,8 +25,6 @@ https://sw.kovidgoyal.net/kitty/actions/#action-toggle-layout
** Easier shortcuts to resize panes ** Easier shortcuts to resize panes
ctrl+shift+arrows ctrl+shift+arrows
* Xonsh * Xonsh
** Fix Ctrl-y
** Make ctrl-w delete path components
** Make interpolation cheatsheet ** Make interpolation cheatsheet
* Nix * Nix
** Replace dotfiles deploy script with home-manager on Nix systems ** Replace dotfiles deploy script with home-manager on Nix systems

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)

View File

@@ -16,6 +16,7 @@ $XONSH_HISTORY_BACKEND = "sqlite"
$HISTCONTROL = "ignoredups" $HISTCONTROL = "ignoredups"
$MULTILINE_PROMPT = " " $MULTILINE_PROMPT = " "
$UPDATE_PROMPT_ON_KEYPRESS = False $UPDATE_PROMPT_ON_KEYPRESS = False
$XONSH_COPY_ON_DELETE = True
$AUTO_CD = True $AUTO_CD = True
@@ -27,7 +28,7 @@ $ALTERNATE_EDITOR = "vim"
$TERMINAL = "kitty" $TERMINAL = "kitty"
config_dir = p"~/.dotfiles/xonsh" config_dir = p"~/.dotfiles/xonsh"
xsh_modules = ["prompt", "path", "alias", "java", "linux", "python", "local", "docker", "kitty", "nix"] xsh_modules = ["prompt", "bindings", "path", "alias", "java", "linux", "python", "local", "docker", "kitty", "nix"]
for module in xsh_modules: for module in xsh_modules:
_p = config_dir / f"{module}.xsh" _p = config_dir / f"{module}.xsh"