Skip to content

docs: 📝 Update wiki powershell-snippet #1542

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

Merged
merged 2 commits into from
Mar 6, 2025
Merged
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
14 changes: 5 additions & 9 deletions .github/wiki/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +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)) {
onefetch
onefetch | Write-Host
}
$global:lastRepository = $currentRepository
}

function Set-Location {
param (
[string]$path
)

# Use the default Set-Location to change the directory
Microsoft.PowerShell.Management\Set-Location -Path $path

# Check if we are in a new Git repository
Microsoft.PowerShell.Management\Set-Location @args
Check-DirectoryForNewRepository
}

Expand Down