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

Powershell "y" alias decoding error. #170

Open
3 tasks done
sxyazi opened this issue Nov 22, 2024 · 2 comments
Open
3 tasks done

Powershell "y" alias decoding error. #170

sxyazi opened this issue Nov 22, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@sxyazi
Copy link
Member

sxyazi commented Nov 22, 2024

Originally posted by @Aqaao in sxyazi/yazi#1921


What system are you running Yazi on?

Windows

What terminal are you running Yazi in?

wezterm

yazi --debug output

None

Describe the bug

Windows powershell Chinese character decoding error when use "y" command.

Minimal reproducer

start yazi via "y" alias, select a path that contains Chinese characters, then press "q" quit yazi.
图片
图片

Anything else?

Resolved via add -Encoding UTF8 arg to Powershell wrapper function's line 4.

$cwd = Get-Content -Path $tmp  -Encoding UTF8 

Maybe docs should be modified to add this arg ?

Validations

  • I tried the latest nightly build, and the issue is still reproducible
  • I updated the debug information (yazi --debug) input box to the nightly that I tried
  • I can reproduce it after disabling all custom configs/plugins (mv ~/.config/yazi ~/.config/yazi-backup)
@sxyazi sxyazi added the help wanted Extra attention is needed label Nov 22, 2024
@luiz00martins
Copy link
Contributor

Hey, @sxyazi! The -Encoding UTF8 solution works fine for me.

This is the final one I'd use:

function y {
    $tmp = [System.IO.Path]::GetTempFileName()
    yazi --cwd-file="$tmp"
    $cwd = Get-Content -Path $tmp -Encoding UTF8
    if (-not [String]::IsNullOrEmpty($cwd) -and $cwd -ne $PWD.Path) {
        $cwd = [System.IO.Path]::GetFullPath($cwd)
        Set-Location -LiteralPath $cwd
    }
    Remove-Item -Path $tmp
}

Also added GetFullPath, to convert possible / to \, if it ever comes to that.

@sxyazi
Copy link
Member Author

sxyazi commented Nov 23, 2024

Nice! Would you like to raise a PR to get the credit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants