From c1eb686cd32ccf78f3d0500ca1c2c9686e3b96ed Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 18 Oct 2025 12:58:43 +0200 Subject: [PATCH] nu: Add sudo toggling key Toggle sudo prefix for command line with . Not sure if I will keep this binding in the long run but it is a good example of command execution using nushell through a key binding. From: https://github.com/nushell/nushell/discussions/16043 --- terminal/.config/nushell/config.nu | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/terminal/.config/nushell/config.nu b/terminal/.config/nushell/config.nu index 48a5fbb..2a97801 100644 --- a/terminal/.config/nushell/config.nu +++ b/terminal/.config/nushell/config.nu @@ -70,6 +70,16 @@ $env.config.keybindings = [ send: OpenEditor } } + { + name: toggle_sudo + modifier: alt + keycode: char_s + mode: [emacs vi_insert vi_normal] + event: { + send: executehostcommand + cmd: "let cmd = (commandline); commandline edit (if $cmd starts-with sudo { $cmd | str replace -r '^sudo ' '' } else { 'sudo ' ++ $cmd });" + } + } { name: run_zoxide modifier: alt