Skip to content

z doesn't register directory in PowerShell #1021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cy-james-lee opened this issue Mar 20, 2025 · 8 comments
Open

z doesn't register directory in PowerShell #1021

cy-james-lee opened this issue Mar 20, 2025 · 8 comments

Comments

@cy-james-lee
Copy link

~> z C:\users
C:Users>z
~>z users
zoxide: no match found
~>pwsh --version
PowerShell 7.5.0
~>zoxide --version
zoxide 0.9.2

Confirmed that zoxide query -l is empty.

@ajeetdsouza
Copy link
Owner

Have you:

  1. Ensured that zoxide is initialized at the end of your config file
  2. cd-ed around normally to populate the database?

@cy-james-lee
Copy link
Author

@ajeetdsouza Yes, I installed following the instruction and put this Invoke-Expression (& { (zoxide init powershell | Out-String) }) into my $PROFILE file. Is it possible that the hook isn't working? function global:__zoxide_hook must not be doing zoxide add.

@rijulkap
Copy link

rijulkap commented Mar 22, 2025

I ran into this same issue earlier this week. Do you also use starship by any chance (and have its init called within your powershell script)? Try using Windows' inbuilt powershell instead of pwsh which is what got it working for me.

@cy-james-lee
Copy link
Author

I ran into this same issue earlier this week. Do you also use starship by any chance (and have its init called within your powershell script)? Try using Windows' inbuilt powershell instead of pwsh which is what got it working for me.

Thanks for the info. Yes, I'm using Starship. Do we have a workaround for this?

@luizxrs
Copy link

luizxrs commented Apr 2, 2025

same problem here, using starship too

@darkmusic
Copy link

If you use starship, just make sure the starship initialization happens before the zoxide initialization.

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

Once you do that, the directory saving/recollection will work correctly in PowerShell.

@rijulkap
Copy link

rijulkap commented Apr 16, 2025

If you use starship, just make sure the starship initialization happens before the zoxide initialization.

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

Once you do that, the directory saving/recollection will work correctly in PowerShell.

In the case of Powershell ( the shell inbuilt in Windows, i.e Version 5.1 and below ), this works and everything works as intended.

When using Powershell Core ( Pwsh or Version 6.x, 7.x (current) ), this still does not work. Even with Zoxide being initialized as the last thing in my powershell profile, the directory saving functionality does not work on visiting new directories. Recollection still works on already registered directories ( as that folder already exists in the db ).

I do intend to look into what could be causing this soonish.

@doums
Copy link

doums commented Apr 17, 2025

Hi, yes I confirm, I'm experiencing the same issue using PS7. I'm not using starship. Zoxide initialized at the end of my PS profile as expected.

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

No branches or pull requests

6 participants