-
Notifications
You must be signed in to change notification settings - Fork 289
Closed
Description
This is a sample script to put in $PROFILE
similar to the ones for bash
, zsh
, or fish
for Powershell to run onefetch
(vanilla command) upon navigating to a git repository.
# git repository greeter
$global:lastRepository = $null
function Check-DirectoryForNewRepository {
$currentRepository = git rev-parse --show-toplevel 2>$null
if ($currentRepository -and ($currentRepository -ne $global:lastRepository)) {
onefetch
}
$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
Check-DirectoryForNewRepository
}
# Optional: Check the repository also when opening a shell directly in a repository directory
# Uncomment the following line if desired
#Check-DirectoryForNewRepository
Metadata
Metadata
Assignees
Labels
No labels