diff options
| author | Tyarel8 <98483313+Tyarel8@users.noreply.github.com> | 2025-06-05 14:28:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-05 13:28:41 +0100 |
| commit | 2e26f34687e18964d0241f251bde1a3629365f24 (patch) | |
| tree | ca1f61cc4a7210a6937c603ac33f6c7e2096a642 /crates | |
| parent | fix: Don't print errors in `zsh_autosuggest` helper (#2780) (diff) | |
| download | atuin-2e26f34687e18964d0241f251bde1a3629365f24.zip | |
fix: `atuin.nu` enchancements (#2778)
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/atuin/src/shell/atuin.nu | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/crates/atuin/src/shell/atuin.nu b/crates/atuin/src/shell/atuin.nu index 32fa65ab..684fd12e 100644 --- a/crates/atuin/src/shell/atuin.nu +++ b/crates/atuin/src/shell/atuin.nu @@ -1,5 +1,14 @@ # Source this in your ~/.config/nushell/config.nu -$env.ATUIN_SESSION = (atuin uuid) +# minimum supported version = 0.93.0 +module compat { + export def --wrapped "random uuid -v 7" [...rest] { atuin uuid } +} +use (if not ( + (version).major > 0 or + (version).minor >= 103 +) { "compat" }) * + +$env.ATUIN_SESSION = (random uuid -v 7 | str replace -a "-" "") hide-env -i ATUIN_HISTORY_ID # Magic token to make sure we don't record commands run by keybindings @@ -24,32 +33,27 @@ let _atuin_pre_prompt = {|| return } with-env { ATUIN_LOG: error } { - do { atuin history end $'--exit=($last_exit)' -- $env.ATUIN_HISTORY_ID } | complete + if (version).minor >= 104 or (version).major > 0 { + job spawn -t atuin { + ^atuin history end $'--exit=($env.LAST_EXIT_CODE)' -- $env.ATUIN_HISTORY_ID | complete + } | ignore + } else { + do { atuin history end $'--exit=($last_exit)' -- $env.ATUIN_HISTORY_ID } | complete + } } hide-env ATUIN_HISTORY_ID } def _atuin_search_cmd [...flags: string] { - let nu_version = do { - let version = version - let major = $version.major? - if $major != null { - # These members are only available in versions > 0.92.2 - [$major $version.minor $version.patch] - } else { - # So fall back to the slower parsing when they're missing - $version.version | split row '.' | into int - } - } [ $ATUIN_KEYBINDING_TOKEN, ([ `with-env { ATUIN_LOG: error, ATUIN_QUERY: (commandline) } {`, - (if $nu_version.0 <= 0 and $nu_version.1 <= 90 { 'commandline' } else { 'commandline edit' }), - (if $nu_version.1 >= 92 { '(run-external atuin search' } else { '(run-external --redirect-stderr atuin search' }), + 'commandline edit', + '(run-external atuin search', ($flags | append [--interactive] | each {|e| $'"($e)"'}), - (if $nu_version.1 >= 92 { ' e>| str trim)' } else {' | complete | $in.stderr | str substring ..-1)'}), + ' e>| str trim)', `}`, ] | flatten | str join ' '), ] | str join "\n" |
