diff options
| author | Lucas Trzesniewski <lucas.trzesniewski@gmail.com> | 2025-12-22 23:22:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-22 22:22:06 +0000 |
| commit | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 (patch) | |
| tree | f3c2fb9f44f6d148527483de600f31d56b493dac /crates | |
| parent | feat: allow disabling sync v1 (#3030) (diff) | |
| download | atuin-8a010fed33ce19a9ddc589196c73c07ba7ba88e7.zip | |
fix(powershell): run `atuin history end` in the background (#3034)
This runs `atuin history end` in the background, since it could delay
the next prompt when syncing.
Sorry I didn't realize this command could be slow (I currently don't use
sync).
I went for the .NET [`Process`
class](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process),
which is not pretty, but the other solutions I thought about all had
their own issues (`Start-Process` needs a file to redirect the output so
you can't just ignore it, `Start-Job` creates job objects that will
linger, `&` does the same but doesn't work on PS 5.1, ...). I'm
surprised I couldn't find a nice way to do the equivalent of `command &
>/dev/null` in PowerShell. 😕
This replaces #3033
## Checks
- [x] I am happy for maintainers to push small adjustments to this PR,
to speed up the review cycle
- [x] I have checked that there are no existing pull requests for the
same thing
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/atuin/src/shell/atuin.ps1 | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/atuin/src/shell/atuin.ps1 b/crates/atuin/src/shell/atuin.ps1 index f1caee86..501c1145 100644 --- a/crates/atuin/src/shell/atuin.ps1 +++ b/crates/atuin/src/shell/atuin.ps1 @@ -51,9 +51,20 @@ New-Module -Name Atuin -ScriptBlock { $duration = (Get-History -Count 1).Duration.Ticks * 100 $durationArg = if ($duration) { "--duration=$duration" } else { $null } - atuin history end --exit=$exitCode $durationArg -- $script:atuinHistoryId | Out-Null + # Fire and forget the atuin history end command to avoid blocking the shell during a potential sync. + $process = New-Object System.Diagnostics.Process + $process.StartInfo.FileName = "atuin" + $process.StartInfo.Arguments = "history end --exit=$exitCode $durationArg -- $script:atuinHistoryId" + $process.StartInfo.UseShellExecute = $false + $process.StartInfo.CreateNoWindow = $true + $process.StartInfo.RedirectStandardInput = $true + $process.StartInfo.RedirectStandardOutput = $true + $process.StartInfo.RedirectStandardError = $true + $process.Start() | Out-Null + $process.StandardInput.Close() + $process.BeginOutputReadLine() + $process.BeginErrorReadLine() - $global:LASTEXITCODE = $exitCode $script:atuinHistoryId = $null } |
