Update configure-git.ps1

This commit is contained in:
Markus Fleschutz 2022-08-29 11:34:30 +02:00
parent f7582355db
commit 8328c1d14f

View File

@ -1,4 +1,4 @@
<#
<#
.SYNOPSIS
Configures Git
.DESCRIPTION
@ -20,16 +20,18 @@
param([string]$FullName = "", [string]$EmailAddress = "", [string]$FavoriteEditor = "")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
"⏳ Step 1/4 - Searching for Git executable..."
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
"⏳ Step 2/4 - Input details..."
if ($FullName -eq "") { $FullName = read-host "Enter your full name" }
if ($EmailAddress -eq "") { $EmailAddress = read-host "Enter your e-mail address"}
if ($FavoriteEditor -eq "") { $FavoriteEditor = read-host "Enter your favorite text editor (emacs,nano,vi,vim,...)" }
$StopWatch = [system.diagnostics.stopwatch]::startNew()
"⏳ Step 1/3: Searching for Git executable..."
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
"⏳ Step 2/3: Configuring basic settings..."
"⏳ Step 3/4 - Saving basic settings (name,email,editor,symlinks,etc.)..."
& git config --global user.name $FullName
& git config --global user.email $EmailAddress
& git config --global core.editor $FavoriteEditor
@ -42,7 +44,7 @@ try {
& git config --global pull.rebase false
if ($lastExitCode -ne "0") { throw "'git config' failed with exit code $lastExitCode" }
"⏳ Step 3/3: Adding basic shortcuts (git st, git ls, etc.)..."
"⏳ Step 4/4 - Saving basic shortcuts (co,br,ci,st,pl,ps,mrg,chp,ls,smu)..."
& git config --global alias.co "checkout"
& git config --global alias.br "branch"
& git config --global alias.ci "commit"
@ -56,7 +58,7 @@ try {
if ($lastExitCode -ne "0") { throw "'git config' failed" }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ saved your personal Git configuration in $Elapsed sec, it's now:"
"✔️ saved your Git configuration in $Elapsed sec, it's now:"
& git config --list
if ($lastExitCode -ne "0") { throw "'git config --list' failed with exit code $lastExitCode" }