Skip to content

fix: set WorkingDirectory in PowerShell Invoke-AtuinSearch#3351

Merged
ellie merged 1 commit intoatuinsh:mainfrom
jamesbrooks:fix/powershell-search-working-directory
Mar 26, 2026
Merged

fix: set WorkingDirectory in PowerShell Invoke-AtuinSearch#3351
ellie merged 1 commit intoatuinsh:mainfrom
jamesbrooks:fix/powershell-search-working-directory

Conversation

@jamesbrooks
Copy link
Copy Markdown
Contributor

Fixes #3350

PowerShell's Set-Location (cd) doesn't update the process-level working directory, so the spawned search process sees a stale cwd and directory filter mode matches against the wrong directory. Setting WorkingDirectory on the ProcessStartInfo ensures the correct cwd is passed through.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 26, 2026

Greptile Summary

Minimal, correct fix for the directory filter mismatch in PowerShell. Sets WorkingDirectory on ProcessStartInfo using $PWD.ProviderPath (the actual filesystem path, not the provider-prefixed path), ensuring the spawned atuin search process sees the right working directory when Set-Location has been used.

Important Files Changed

Filename Overview
crates/atuin/src/shell/atuin.ps1 Adds WorkingDirectory = $PWD.ProviderPath to ProcessStartInfo so the spawned atuin process inherits the correct cwd in PowerShell.

Reviews (1): Last reviewed commit: "fix: set WorkingDirectory in PowerShell ..." | Re-trigger Greptile

@ltrzesniewski
Copy link
Copy Markdown
Contributor

ltrzesniewski commented Mar 26, 2026

FML 🤦

image

Thanks for fixing this!

Could you just please replace $PWD.ProviderPath with (Get-Location).ProviderPath, since $PWD can be overwritten? Thanks!

Note: I didn't check if that works, and obviously PowerShell is full of surprises...

@jamesbrooks jamesbrooks force-pushed the fix/powershell-search-working-directory branch from 247fb8a to dbfe19e Compare March 26, 2026 13:18
@jamesbrooks
Copy link
Copy Markdown
Contributor Author

replace $PWD.ProviderPath with (Get-Location).ProviderPath, since $PWD can be overwritten?

Yep that makes perfect sense, updated!

PowerShell is full of surprises

My daily driver is a mac so I'm only occasionally on PowerShell. I was excited to see atuin available on Windows, then saddened when the directory filter didn't work the way I knew and loved ;)

@ltrzesniewski
Copy link
Copy Markdown
Contributor

ltrzesniewski commented Mar 26, 2026

Sorry to bother you again, but I was in a hurry when I wrote my previous comment. According to this SO answer, the most robust way to get the filesystem path is: (Get-Location -PSProvider FileSystem).ProviderPath

I would never had thought that cd didn't change the process' working directory when using a filesystem drive... 🤦

The Atuin module doesn't like being in a non-filesystem location, but that's a different problem I can take a look at later. Fixed in #3353

Use (Get-Location -PSProvider FileSystem).ProviderPath to reliably
get the filesystem path, since $PWD is a writable automatic variable
that can be overwritten.
@jamesbrooks jamesbrooks force-pushed the fix/powershell-search-working-directory branch from dbfe19e to c8b4400 Compare March 26, 2026 20:39
@jamesbrooks
Copy link
Copy Markdown
Contributor Author

No worries, updated! :) thanks.

Copy link
Copy Markdown
Contributor

@ltrzesniewski ltrzesniewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Copy link
Copy Markdown
Member

@ellie ellie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you both!

@ellie ellie merged commit 844c3ba into atuinsh:main Mar 26, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Interactive search directory filter uses wrong directory on PowerShell

3 participants