Update cd-repos.ps1

This commit is contained in:
Markus Fleschutz 2022-10-24 12:24:35 +02:00
parent 88f2492f99
commit 45f96fa3a2

View File

@ -1,11 +1,11 @@
<#
.SYNOPSIS
Sets the working directory to the user's Git repositories folder
Sets the working directory to the user's repos folder
.DESCRIPTION
This PowerShell script changes the working directory to the user's Git repositories folder.
.EXAMPLE
PS> ./cd-repos
📂/home/Markus/Repos
📂C:\Users\Markus\Repos
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -15,7 +15,11 @@
try {
$Path = Resolve-Path "$HOME/Repos"
if (-not(Test-Path "$Path" -pathType container)) {
throw "Git repositories folder at 📂$Path doesn't exist (yet)"
$Path = Resolve-Path "$HOME/source/repos"
if (-not(Test-Path "$Path" -pathType container)) {
$Path = Resolve-Path "$HOME/Repos"
throw "Folder for Git repositories at 📂$Path doesn't exist (yet)"
}
}
Set-Location "$Path"
"📂$Path"
@ -23,4 +27,4 @@ try {
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
}