mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-09 01:38:26 +02:00
Updated cd-repo.ps1
This commit is contained in:
parent
0685c79a49
commit
c594e15920
@ -2,12 +2,13 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to a repository
|
Sets the working directory to a repository
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to a Git repository.
|
This PowerShell script changes the working directory to a local Git repository.
|
||||||
.PARAMETER folderName
|
.PARAMETER folderName
|
||||||
Specifies the folder name
|
Specifies the Git repository's folder name
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-repo.ps1 rust
|
PS> ./cd-repo.ps1 rust
|
||||||
📂C:\Repos\rust • on Git branch: ## main ... origin/main
|
📂C:\Repos\rust
|
||||||
|
on branch: ## main ... origin/main
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -17,7 +18,7 @@
|
|||||||
param([string]$folderName = "")
|
param([string]$folderName = "")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ("$folderName" -eq "") { $folderName = Read-Host "Enter the folder name" }
|
if ("$folderName" -eq "") { $folderName = Read-Host "Enter the Git repository's folder name" }
|
||||||
|
|
||||||
if (Test-Path "$HOME/Repos/" -pathType Container) { # try short name
|
if (Test-Path "$HOME/Repos/" -pathType Container) { # try short name
|
||||||
$path = "$HOME/Repos/"
|
$path = "$HOME/Repos/"
|
||||||
@ -39,7 +40,7 @@ try {
|
|||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
Write-Host "📂$path"
|
Write-Host "📂$path"
|
||||||
|
|
||||||
Write-Host "🌵Git branch " -noNewline
|
Write-Host " on branch: " -noNewline
|
||||||
& git status --short --branch --show-stash
|
& git status --short --branch --show-stash
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user