From 1365fcc487c08262af2e32aad7e3f8e4c18d1f06 Mon Sep 17 00:00:00 2001 From: FallenDeity <61227305+FallenDeity@users.noreply.github.com> Date: Wed, 5 Mar 2025 17:29:56 +0530 Subject: [PATCH 1/2] docs: :memo: Update wiki powershell-snippet Update powershell-snippet in wiki to play nice with zoxide, yazi etc --- .github/wiki/Getting-Started.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/wiki/Getting-Started.md b/.github/wiki/Getting-Started.md index 6530463c4..3fb42d94d 100644 --- a/.github/wiki/Getting-Started.md +++ b/.github/wiki/Getting-Started.md @@ -131,20 +131,27 @@ $global:lastRepository = $null function Check-DirectoryForNewRepository { $currentRepository = git rev-parse --show-toplevel 2>$null if ($currentRepository -and ($currentRepository -ne $global:lastRepository)) { - onefetch + if ([Console]::OutputEncoding -ne [System.Text.Encoding]::UTF8) { + [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + } + onefetch | Write-Host } $global:lastRepository = $currentRepository } function Set-Location { param ( - [string]$path + [string]$Path, + [string]$LiteralPath ) - # Use the default Set-Location to change the directory - Microsoft.PowerShell.Management\Set-Location -Path $path + if ($LiteralPath) { + Microsoft.PowerShell.Management\Set-Location -LiteralPath $LiteralPath + } + else { + Microsoft.PowerShell.Management\Set-Location -Path $Path + } - # Check if we are in a new Git repository Check-DirectoryForNewRepository } From c45b7a4322f90364d2150e4761beb1ce78e28039 Mon Sep 17 00:00:00 2001 From: FallenDeity <61227305+FallenDeity@users.noreply.github.com> Date: Wed, 5 Mar 2025 23:37:25 +0530 Subject: [PATCH 2/2] docs: :memo: Update wiki powershell-snippet Set global encoding confing for zoxide and simplify Set-Location function --- .github/wiki/Getting-Started.md | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/wiki/Getting-Started.md b/.github/wiki/Getting-Started.md index 3fb42d94d..91c3124b8 100644 --- a/.github/wiki/Getting-Started.md +++ b/.github/wiki/Getting-Started.md @@ -126,32 +126,21 @@ An adaptation of the above snippet suited for `Powershell`. Put this script in t ```pwsh # git repository greeter + +# Set the console output encoding to UTF-8, so that special characters are displayed correctly when piping to Write-Host +[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $global:lastRepository = $null function Check-DirectoryForNewRepository { $currentRepository = git rev-parse --show-toplevel 2>$null if ($currentRepository -and ($currentRepository -ne $global:lastRepository)) { - if ([Console]::OutputEncoding -ne [System.Text.Encoding]::UTF8) { - [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 - } onefetch | Write-Host } $global:lastRepository = $currentRepository } function Set-Location { - param ( - [string]$Path, - [string]$LiteralPath - ) - - if ($LiteralPath) { - Microsoft.PowerShell.Management\Set-Location -LiteralPath $LiteralPath - } - else { - Microsoft.PowerShell.Management\Set-Location -Path $Path - } - + Microsoft.PowerShell.Management\Set-Location @args Check-DirectoryForNewRepository }