Updated cd-repos.ps1

This commit is contained in:
Markus Fleschutz 2025-02-19 14:28:03 +01:00
parent ec7d84b0e0
commit f1ba19a6ad

View File

@ -2,9 +2,7 @@
.SYNOPSIS .SYNOPSIS
Sets the working directory to the Git repos folder Sets the working directory to the Git repos folder
.DESCRIPTION .DESCRIPTION
This PowerShell script changes the working directory to the Git repositories folder. This PowerShell script changes the working directory to the folder for Git repositories.
.PARAMETER subpath
Specifies an additional relative subpath (optional)
.EXAMPLE .EXAMPLE
PS> ./cd-repos.ps1 PS> ./cd-repos.ps1
📂C:\Repos 📂C:\Repos
@ -15,26 +13,18 @@
#> #>
try { try {
if (Test-Path "~/Repos" -pathType Container) { # try short name in home dir if (Test-Path "~/Repos" -pathType container) { $path = "~/Repos"
$path = "~/Repos" } elseif (Test-Path "~/repos" -pathType container) { $path = "~/repos"
} elseif (Test-Path "~/repos" -pathType Container) { } elseif (Test-Path "~/Repositories" -pathType container) { $path = "~/Repositories"
$path = "~/repos" } elseif (Test-Path "~/repositories" -pathType container) { $path = "~/repositories"
} elseif (Test-Path "~/Repositories" -pathType Container) { # try long name } elseif (Test-Path "/Repos" -pathType container) { $path = "/Repos"
$path = "~/Repositories" } elseif (Test-Path "/repos" -pathType container) { $path = "/repos"
} elseif (Test-Path "~/repositories" -pathType Container) { } elseif (Test-Path "/Repositories" -pathType container) { $path = "/Repositories"
$path = "~/repositories" } elseif (Test-Path "/repositories" -pathType container) { $path = "/repositories"
} elseif (Test-Path "/Repos" -pathType Container) { # try short name in root dir } elseif (Test-Path "~/source/repos" -pathType container) { $path = "~/source/repos" # Visual Studio default
$path = "/Repos" } elseif (Test-Path "D:/Repos" -pathType container) { $path = "D:/Repos" # second HDD
} elseif (Test-Path "/repos" -pathType Container) {
$path = "/repos"
} elseif (Test-Path "/Repositories" -pathType Container) { # try long name
$path = "/Repositories"
} elseif (Test-Path "/repositories" -pathType Container) {
$path = "/repositories"
} elseif (Test-Path "~/source/repos" -pathType Container) { # try Visual Studio default
$path = "~/source/repos"
} else { } else {
throw "No Git repositories folder in your home directory or in the root folder yet" throw "No folder for Git repositories yet (in home or root directory)"
} }
$path = Resolve-Path $path $path = Resolve-Path $path
Set-Location "$path" Set-Location "$path"