refactor(input): harmonize word deletion and modifier keybindings across bash, nvim, tmux, and alacritty
This commit standardizes and refines word deletion behavior and modifier key handling across the entire terminal and editor stack. - Bash: Add interactive Readline keybindings for `Ctrl+W`, `Ctrl+Delete`, and `Ctrl+Backspace` word deletion. - Neovim: Configure precision word deletion shortcuts in insert and normal modes. - Tmux: Enable `extended-keys` and terminal feature flags to pass modifier combos. - Alacritty: Bind `Ctrl+Delete` and `Ctrl+Back` to raw ANSI escape sequences.
This commit is contained in:
1 parent
f5f921bb13
commit
53847d3496
4 files changed
+47
-1
No files matched your search
@@ -200,6 +200,19 @@
|
||||
${builtins.readFile ./shell/quicklinks.sh} # Interactive fzf web launcher
|
||||
${builtins.readFile ./shell/jump.sh} # Directory jumper & interactive fuzzy navigation
|
||||
|
||||
# --- Word Deletion & Readline Keybindings ---
|
||||
if [[ -n "$BASH_VERSION" ]] && [[ "$-" == *i* ]]; then
|
||||
# Ctrl+W: Delete entire word under cursor (backward-word + kill-word)
|
||||
bind '"\C-w": "\eb\ed"' 2>/dev/null
|
||||
|
||||
# Ctrl+Delete: Forward word delete (matches Alacritty \e[3;5~)
|
||||
bind '"\e[3;5~": kill-word' 2>/dev/null
|
||||
|
||||
# Ctrl+Backspace / Alt+Backspace: Backward word delete (start to cursor)
|
||||
bind '"\e\x7f": backward-kill-word' 2>/dev/null
|
||||
bind '"\e\b": backward-kill-word' 2>/dev/null
|
||||
fi
|
||||
|
||||
# --- Visual Entry ---
|
||||
# Display system information dashboard upon opening interactive shells
|
||||
if [[ $- == *i* ]]; then
|
||||
|
||||
@@ -28,6 +28,30 @@ vim.keymap.set('i', '<Tab>', function()
|
||||
end
|
||||
end, { expr = true, silent = true })
|
||||
|
||||
-- =============================================================================
|
||||
-- Precision Word Deletion Shortcuts
|
||||
-- =============================================================================
|
||||
|
||||
-- 1. Delete word backward: from word start to cursor (built-in <C-w> = backward-kill-word).
|
||||
-- noremap=true (default) ensures this calls Vim's native handler, NOT our custom <C-w> below.
|
||||
vim.keymap.set('i', '<C-BS>', '<C-w>', { desc = 'Delete word backward (start to cursor)' })
|
||||
vim.keymap.set('i', '<M-BS>', '<C-w>', { desc = 'Delete word backward (start to cursor)' })
|
||||
vim.keymap.set('i', '<M-BSpace>', '<C-w>', { desc = 'Delete word backward (start to cursor)' })
|
||||
|
||||
-- 2. Delete word forward: from cursor to word end (preserves trailing whitespace)
|
||||
vim.keymap.set('i', '<C-Delete>', '<C-o>de', { desc = 'Delete word forward (cursor to end)' })
|
||||
vim.keymap.set('i', '<M-Delete>', '<C-o>de', { desc = 'Delete word forward (cursor to end)' })
|
||||
|
||||
-- 3. Delete entire word under cursor (inner word), regardless of cursor position
|
||||
vim.keymap.set('i', '<C-w>', '<C-o>diw', { desc = 'Delete entire word under cursor' })
|
||||
|
||||
-- Normal Mode parity
|
||||
vim.keymap.set('n', '<C-Delete>', 'de', { desc = 'Delete word forward' })
|
||||
vim.keymap.set('n', '<M-Delete>', 'de', { desc = 'Delete word forward' })
|
||||
vim.keymap.set('n', '<C-BS>', 'db', { desc = 'Delete word backward' })
|
||||
vim.keymap.set('n', '<M-BS>', 'db', { desc = 'Delete word backward' })
|
||||
vim.keymap.set('n', '<M-BSpace>', 'db', { desc = 'Delete word backward' })
|
||||
|
||||
-- =============================================================================
|
||||
-- Window / Tmux Seamless Navigation (Ctrl-h/j/k/l)
|
||||
-- =============================================================================
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
set -g default-terminal "tmux-256color"
|
||||
|
||||
# Advertise true color / RGB support to terminal applications (Neovim, etc.)
|
||||
# Advertise true color / RGB and extended keys support to terminal applications (Neovim, etc.)
|
||||
set -as terminal-features ',*:RGB'
|
||||
set -as terminal-features 'xterm*:extkeys'
|
||||
set -s extended-keys on
|
||||
|
||||
# 1-based indexing for windows and panes (matches keyboard row 1..9)
|
||||
set -g base-index 1
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
# Parse true ASCII Escape (0x1b) and DEL (0x7f) bytes so TOML serialization generates real escape sequences
|
||||
esc = builtins.fromJSON "\"\\u001b\"";
|
||||
del = builtins.fromJSON "\"\\u007f\"";
|
||||
in
|
||||
{
|
||||
# GPU-Accelerated Terminal Emulator (Alacritty)
|
||||
programs.alacritty = {
|
||||
@@ -59,6 +64,8 @@
|
||||
{ key = "Minus"; mods = "Control"; action = "DecreaseFontSize"; }
|
||||
{ key = "Key0"; mods = "Control"; action = "ResetFontSize"; }
|
||||
{ key = "Enter"; mods = "Shift"; chars = "\n"; }
|
||||
{ key = "Delete"; mods = "Control"; chars = "${esc}[3;5~"; }
|
||||
{ key = "Back"; mods = "Control"; chars = "${esc}${del}"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user