From c26db619ac91239f9ed4b4f954b5beaea25542b4 Mon Sep 17 00:00:00 2001 From: rootiest Date: Sun, 26 Apr 2026 01:45:56 -0400 Subject: [PATCH] feat(keybindings): add Ctrl+Alt+U to replace first command token --- conf.d/keybindings.fish | 11 +++++++++++ functions/_replace_command_token.fish | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 conf.d/keybindings.fish create mode 100644 functions/_replace_command_token.fish diff --git a/conf.d/keybindings.fish b/conf.d/keybindings.fish new file mode 100644 index 0000000..9c1c2e9 --- /dev/null +++ b/conf.d/keybindings.fish @@ -0,0 +1,11 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later + +if not status is-interactive + exit +end + +# Ctrl+Alt+U — strip the first command token and place cursor at start to retype it +for mode in default insert + bind --mode $mode ctrl-alt-u _replace_command_token +end diff --git a/functions/_replace_command_token.fish b/functions/_replace_command_token.fish new file mode 100644 index 0000000..b0064cb --- /dev/null +++ b/functions/_replace_command_token.fish @@ -0,0 +1,6 @@ +function _replace_command_token --description 'Remove first token from commandline and place cursor at start' + set -l cmd (commandline) + set -l rest (string replace -r '^\S+\s*' '' -- $cmd) + commandline -- $rest + commandline -C 0 +end