nu: Add space prefix to keybind commands to prevent history adding

To prevent adding any of the keyboard-binding driven commands to the
user's command history, we simply prefix all of them with a single
space.
This commit is contained in:
Marty Oehme 2025-11-14 14:12:24 +01:00
parent b305be8ad0
commit bfecbdcd59
Signed by: Marty
GPG key ID: 4E535BC19C61886E

View file

@ -82,7 +82,7 @@ $env.config.keybindings = [
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 });"
cmd: " let cmd = (commandline); commandline edit (if $cmd starts-with sudo { $cmd | str replace -r '^sudo ' '' } else { 'sudo ' ++ $cmd });"
}
}
{
@ -105,7 +105,7 @@ $env.config.keybindings = [
mode: ["emacs", "vi_normal", "vi_insert"]
event: {
send: executehostcommand
cmd: "zoxide query --interactive"
cmd: " zoxide query --interactive"
}
}
{
@ -115,7 +115,7 @@ $env.config.keybindings = [
mode: [ "vi_normal"]
event: {
send: executehostcommand
cmd: "zoxide query --interactive"
cmd: " zoxide query --interactive"
}
}
{
@ -125,7 +125,8 @@ $env.config.keybindings = [
mode: ["emacs", "vi_normal", "vi_insert"]
event: {
send: executehostcommand
cmd: "
# intentional eol space to prevent adding cmd to history
cmd: "
let fzf_ctrl_t_command = \$\"fd --type file --hidden | fzf --preview 'bat --color=always --style=full --line-range=:500 {}' \";
let result = nu -l -i -c $fzf_ctrl_t_command;
commandline edit --append $result;