Update cd-repos.ps1

This commit is contained in:
Markus Fleschutz 2022-11-08 21:02:45 +01:00
parent 7de3ba458b
commit bfde55932f

View File

@ -5,7 +5,7 @@
This PowerShell script changes the working directory to the user's Git repositories folder. This PowerShell script changes the working directory to the user's Git repositories folder.
.EXAMPLE .EXAMPLE
PS> ./cd-repos PS> ./cd-repos
📂C:\Users\Markus\source\repos 📂C:\Users\Markus\Repos
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -13,12 +13,14 @@
#> #>
try { try {
if ($IsLinux) { if (Test-Path "$HOME/Repos" -pathType Container) {
$Path = Resolve-Path "$HOME/Repos" $Path = Resolve-Path "$HOME/Repos"
} else { } elseif (Test-Path "$HOME/Repositories" -pathType Container) {
$Path = Resolve-Path "$HOME/Repositories"
} elseif (Test-Path "$HOME/source/repos" -pathType Container) {
$Path = Resolve-Path "$HOME/source/repos" $Path = Resolve-Path "$HOME/source/repos"
} } else {
if (-not(Test-Path "$Path" -pathType container)) { $Path = "$HOME/Repos"
throw "Folder for Git repositories at 📂$Path doesn't exist (yet)" throw "Folder for Git repositories at 📂$Path doesn't exist (yet)"
} }
Set-Location "$Path" Set-Location "$Path"