From 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 Mon Sep 17 00:00:00 2001 From: Lucas Trzesniewski Date: Mon, 22 Dec 2025 23:22:06 +0100 Subject: fix(powershell): run `atuin history end` in the background (#3034) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- crates/atuin/src/shell/atuin.ps1 | 15 +++++++++++++-- 1 file 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 } -- cgit v1.3.1