fix: Don't print errors in zsh_autosuggest helper (#2780)

Previously, this would result in long multi-line errors when typing,
making it hard to see the shell prompt:
```
$  Error: could not load client settings

Caused by:
   0: could not create config file
   1: failed to create file `/home/jyn/.config/atuin/config.toml`
   2: Required key not available (os error 126)

Location:
    atuin-client/src/settings.rs:675:54
 fError: could not load client settings

Caused by:
   0: could not create config file
   1: failed to create file `/home/jyn/.config/atuin/config.toml`
   2: Required key not available (os error 126)

Location:
    atuin-client/src/settings.rs:675:54
 faError: could not load client settings
```

Silence these in autosuggestions, such that they only show up when
explicitly invoking atuin.
This commit is contained in:
jyn
2025-06-05 08:26:37 -04:00
committed by GitHub
parent 239e6fbe7c
commit 2814c2031c

View File

@@ -15,7 +15,8 @@ zmodload zsh/datetime 2>/dev/null
# you'd like to override this, then add your config after the $(atuin init zsh)
# in your .zshrc
_zsh_autosuggest_strategy_atuin() {
suggestion=$(ATUIN_QUERY="$1" atuin search --cmd-only --limit 1 --search-mode prefix)
# silence errors, since we don't want to spam the terminal prompt while typing.
suggestion=$(ATUIN_QUERY="$1" atuin search --cmd-only --limit 1 --search-mode prefix 2>/dev/null)
}
if [ -n "${ZSH_AUTOSUGGEST_STRATEGY:-}" ]; then