ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
20.54k stars 523 forks source link

zoxide is not working on Windows 11 running in pwsh (open source PowerShell) #707

Closed Treit closed 4 months ago

Treit commented 5 months ago

I installed zoxide via cargo install zoxide and added the line to my PowerShell (pwsh) $profile per the installation instructions:

Invoke-Expression (& { (zoxide init powershell | Out-String) })

I can switch to directories but it doesn't seem to record them:

~ via 🐍 v3.11.8
[14:25:56] ✓ z tools

~/tools
[14:26:00] ✓ zoxide query
zoxide: no match found

Not sure how to troubleshoot it further.

edzhangsy commented 5 months ago

I encountered the same problem. And it seems you are using the starship, too. The powershell setup line should be added below the starship setup line. After the change, open a new pwsh to test. Then the zoxide should work.

pybash1 commented 4 months ago

also facing this issue with the zoxide line at the bottom of my config

Treit commented 4 months ago

I can confirm that moving the zoxide init line to after the Starship init line seems to have fixed it.

Invoke-Expression (&starship init powershell)
Invoke-Expression (& { (zoxide init powershell | Out-String) })
pybash1 commented 4 months ago

i dont have starship(i use oh-my-posh)...

ajeetdsouza commented 4 months ago

@pybash1 oh-my-posh is also a custom prompt and has the same issue. You can resolve this by moving Invoke-Expression (& { (zoxide init powershell | Out-String) }) to the last line in your config.

alex1yaremchuk commented 2 months ago

Moving init to the end of pwsh config helped me too. Thanks!

UPDATE: No, it doesn't work (somehow one path was added but not more). Actually it shouldn't help in my case as other entries are function definitions in my profile.

will have to be moving from so much hyped zoxide.

ajeetdsouza commented 2 months ago

@alex1yaremchuk can you create an issue describing your problem?

j2ghz commented 1 month ago

@alex1yaremchuk can you create an issue describing your problem?

I had the same issue. What tripped me up is that once Invoke-Expression (& { (zoxide init powershell | Out-String) }) runs too early (before starship), rerunning it will not fix the issues. The only fix is to reorder them in you $PROFILE, you can't test it after a wrongly-ordered has already been executed. I don't know why, that's just what my testing shows. For reference my order after the fix is: PSReadLine, starship, zoxide and posh-git, and everything seems to work well.