diff options
| -rw-r--r-- | crates/atuin/src/command/client/search/interactive.rs | 4 | ||||
| -rw-r--r-- | crates/atuin/src/shell/atuin.nu | 42 |
2 files changed, 33 insertions, 13 deletions
diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs index f50568e7..bcf456a4 100644 --- a/crates/atuin/src/command/client/search/interactive.rs +++ b/crates/atuin/src/command/client/search/interactive.rs @@ -1418,7 +1418,7 @@ pub async fn history( if accept && matches!( Shell::from_env(), - Shell::Zsh | Shell::Fish | Shell::Bash | Shell::Xonsh + Shell::Zsh | Shell::Fish | Shell::Bash | Shell::Xonsh | Shell::Nu ) { command = String::from("__atuin_accept__:") + &command; @@ -1438,7 +1438,7 @@ pub async fn history( } else if accept && matches!( Shell::from_env(), - Shell::Zsh | Shell::Fish | Shell::Bash | Shell::Xonsh + Shell::Zsh | Shell::Fish | Shell::Bash | Shell::Xonsh | Shell::Nu ) { command = String::from("__atuin_accept__:") + &command; diff --git a/crates/atuin/src/shell/atuin.nu b/crates/atuin/src/shell/atuin.nu index 0e4ff691..190f3117 100644 --- a/crates/atuin/src/shell/atuin.nu +++ b/crates/atuin/src/shell/atuin.nu @@ -46,17 +46,37 @@ let _atuin_pre_prompt = {|| } def _atuin_search_cmd [...flags: string] { - [ - $ATUIN_KEYBINDING_TOKEN, - ([ - `with-env { ATUIN_LOG: error, ATUIN_QUERY: (commandline) } {`, - 'commandline edit', - '(run-external atuin search', - ($flags | append [--interactive] | each {|e| $'"($e)"'}), - ' e>| str trim)', - `}`, - ] | flatten | str join ' '), - ] | str join "\n" + if (version).minor >= 106 or (version).major > 0 { + [ + $ATUIN_KEYBINDING_TOKEN, + ([ + `with-env { ATUIN_LOG: error, ATUIN_QUERY: (commandline), ATUIN_SHELL: nu } {`, + ([ + 'let output = (run-external atuin search', + ($flags | append [--interactive] | each {|e| $'"($e)"'}), + 'e>| str trim)', + ] | flatten | str join ' '), + 'if ($output | str starts-with "__atuin_accept__:") {', + 'commandline edit --accept ($output | str replace "__atuin_accept__:" "")', + '} else {', + 'commandline edit $output', + '}', + `}`, + ] | flatten | str join "\n"), + ] + } else { + [ + $ATUIN_KEYBINDING_TOKEN, + ([ + `with-env { ATUIN_LOG: error, ATUIN_QUERY: (commandline) } {`, + 'commandline edit', + '(run-external atuin search', + ($flags | append [--interactive] | each {|e| $'"($e)"'}), + ' e>| str trim)', + `}`, + ] | flatten | str join ' '), + ] + } | str join "\n" } $env.config = ($env | default {} config).config |
