mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-19 08:52:05 +02:00
Updated the manuals
This commit is contained in:
@@ -6,9 +6,9 @@ This PowerShell script changes the working directory to the user's Git repositor
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./cd-repos.ps1 [[-Subpath] <String>] [<CommonParameters>]
|
||||
PS> ./cd-repos.ps1 [[-subpath] <String>] [<CommonParameters>]
|
||||
|
||||
-Subpath <String>
|
||||
-subpath <String>
|
||||
Specifies an additional relative subpath (optional)
|
||||
|
||||
Required? false
|
||||
@@ -26,7 +26,13 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-repos
|
||||
📂C:\Users\Markus\source\Repos
|
||||
📂C:\Users\Markus\Repos
|
||||
|
||||
|
||||
|
||||
PS> ./cd-repos rust
|
||||
📂C:\Users\Markus\Repos\rust
|
||||
on branch: ## main ... origin/main
|
||||
|
||||
```
|
||||
|
||||
@@ -46,33 +52,47 @@ Script Content
|
||||
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.
|
||||
.PARAMETER Subpath
|
||||
.PARAMETER subpath
|
||||
Specifies an additional relative subpath (optional)
|
||||
.EXAMPLE
|
||||
PS> ./cd-repos
|
||||
📂C:\Users\Markus\source\Repos
|
||||
📂C:\Users\Markus\Repos
|
||||
|
||||
PS> ./cd-repos rust
|
||||
📂C:\Users\Markus\Repos\rust
|
||||
on branch: ## main ... origin/main
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$Subpath = "")
|
||||
param([string]$subpath = "")
|
||||
|
||||
try {
|
||||
if (Test-Path "$HOME/Repos" -pathType Container) { # try short name
|
||||
$Path = "$HOME/Repos/$Subpath"
|
||||
} elseif (Test-Path "$HOME/Repositories" -pathType Container) { # try long name
|
||||
$Path = "$HOME/Repositories/$Subpath"
|
||||
} elseif (Test-Path "$HOME/source/repos" -pathType Container) { # try Visual Studio default
|
||||
$Path = "$HOME/source/repos/$Subpath"
|
||||
if (Test-Path "$HOME/Repos/" -pathType Container) { # try short name
|
||||
$path = "$HOME/Repos/"
|
||||
} elseif (Test-Path "$HOME/repos/" -pathType Container) {
|
||||
$path = "$HOME/repos/"
|
||||
} elseif (Test-Path "$HOME/Repositories/" -pathType Container) { # try long name
|
||||
$path = "$HOME/Repositories/"
|
||||
} elseif (Test-Path "$HOME/source/repos/" -pathType Container) { # try Visual Studio default
|
||||
$path = "$HOME/source/repos/"
|
||||
} elseif (Test-Path "/Repos/" -pathType Container) {
|
||||
$path = "/Repos/"
|
||||
} else {
|
||||
throw "The folder for Git repositories in your home directory doesn't exist (yet)."
|
||||
throw "The folder for Git repositories doesn't exist (yet)"
|
||||
}
|
||||
if ("$subpath" -ne "") { $path += $subpath }
|
||||
if (-not(Test-Path "$path" -pathType Container)) { throw "The path to 📂$path doesn't exist (yet)" }
|
||||
$path = Resolve-Path "$path"
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
|
||||
if ("$subpath" -ne "") {
|
||||
Write-Host -noNewline " on branch: "
|
||||
& git status --short --branch --show-stash
|
||||
}
|
||||
if (-not(Test-Path "$Path" -pathType Container)) { throw "The path to 📂$Path doesn't exist (yet)." }
|
||||
$Path = Resolve-Path "$Path"
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
@@ -80,4 +100,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-repos.ps1 as of 01/25/2024 13:58:36)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-repos.ps1 as of 03/27/2024 17:36:23)*
|
||||
|
Reference in New Issue
Block a user