Skip to content
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

fixed the issue for powershell env variable #910

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions templates/powershell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ function global:__zoxide_pwd {

# cd + custom logic based on the value of _ZO_ECHO.
function global:__zoxide_cd($dir, $literal) {

if ($dir.StartsWith('%') -and $dir.EndsWith('%')) {
$envVar = $dir.Trim('%')
$dir = $env:$envVar
Copy link

@WiIIiamWei WiIIiamWei Oct 7, 2024

Choose a reason for hiding this comment

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

I've tested on this, but your code seems to be generating errors when I load the profile on my machine.

I think you meant to write this at 33:

        $dir = ${env:$envVar}

I tried to fix this too and comes up with a different approach (at #911), which might be covering more cases than your solution. Looking for reviews too.

Copy link
Author

Choose a reason for hiding this comment

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

Upon reviewing the repository locally on my machine, I realized the fix could be related to the powershell.txt file, specifically within the __zoxide_cd function, but since I'm currently working on a Linux machine, I wasn't able to test it. I apologize for submitting the PR without proper testing.

}

$dir = if ($literal) {
Set-Location -LiteralPath $dir -Passthru -ErrorAction Stop
} else {
Expand Down
Loading