Handle UTF-8 output correctly in PowerShell

This commit is contained in:
Ajeet D'Souza 2022-09-18 11:33:41 +05:30
parent c137019b83
commit 9d9bcfcac2
2 changed files with 18 additions and 4 deletions

View File

@ -11,7 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- zsh: completions clashing with `zsh-autocomplete`.
- Zsh: completions clashing with `zsh-autocomplete`.
- Fzf: 'invalid option' on macOS.
- PowerShell: handle UTF-8 encoding correctly.
## [0.8.3] - 2022-09-02

View File

@ -5,6 +5,18 @@
# Utility functions for zoxide.
#
# Call zoxide binary, returning the output as UTF-8.
function __zoxide_bin {
$encoding = [Console]::OutputEncoding
try {
[Console]::OutputEncoding = [System.Text.Utf8Encoding]::new()
$result = zoxide @args
return $result
} finally {
[Console]::OutputEncoding = $encoding
}
}
# pwd based on zoxide's format.
function __zoxide_pwd {
$cwd = Get-Location
@ -86,10 +98,10 @@ function __zoxide_z {
else {
$result = __zoxide_pwd
if ($null -ne $result) {
$result = zoxide query --exclude $result -- @args
$result = __zoxide_bin query --exclude $result -- @args
}
else {
$result = zoxide query -- @args
$result = __zoxide_bin query -- @args
}
if ($LASTEXITCODE -eq 0) {
__zoxide_cd $result $true
@ -99,7 +111,7 @@ function __zoxide_z {
# Jump to a directory using interactive search.
function __zoxide_zi {
$result = zoxide query -i -- @args
$result = __zoxide_bin query -i -- @args
if ($LASTEXITCODE -eq 0) {
__zoxide_cd $result $true
}