refactor(nushell): update commandline syntax, closes #1733 (#1735)

* refactor(nushell): update `commandline` syntax, closes #1733

* refactor(nushell): add backwards compatibility for *Nushell* v0.90.x
This commit is contained in:
Steven Xu 2024-02-20 19:19:33 +11:00 committed by GitHub
parent 2a65f89cd5
commit 1c29702e44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,10 +28,12 @@ let _atuin_pre_prompt = {||
} }
def _atuin_search_cmd [...flags: string] { def _atuin_search_cmd [...flags: string] {
let nu_version = ($env.NU_VERSION | split row '.' | each { || into int })
[ [
$ATUIN_KEYBINDING_TOKEN, $ATUIN_KEYBINDING_TOKEN,
([ ([
`commandline (ATUIN_LOG=error run-external --redirect-stderr atuin search`, (if $nu_version.0 <= 0 and $nu_version.1 <= 90 { 'commandline' } else { 'commandline edit' }),
`(ATUIN_LOG=error run-external --redirect-stderr atuin search`,
($flags | append [--interactive, --] | each {|e| $'"($e)"'}), ($flags | append [--interactive, --] | each {|e| $'"($e)"'}),
`(commandline) | complete | $in.stderr | str substring ..-1)`, `(commandline) | complete | $in.stderr | str substring ..-1)`,
] | flatten | str join ' '), ] | flatten | str join ' '),