Update cd-home.ps1 and list-workdir.ps1

This commit is contained in:
Markus Fleschutz 2022-12-28 15:24:29 +01:00
parent 1cca88c32b
commit c8efe1f4ec
2 changed files with 8 additions and 8 deletions

View File

@ -1,6 +1,6 @@
<#
.SYNOPSIS
Sets the working directory to the user's home directory
Sets the working directory to the user's home folder
.DESCRIPTION
This PowerShell script changes the working directory to the user's home directory.
.EXAMPLE
@ -13,13 +13,13 @@
#>
try {
$Path = Resolve-Path "$HOME"
if (-not(Test-Path "$Path" -pathType container)) {
throw "Home directory at 📂$Path doesn't exist (yet)"
$Path = Resolve-Path -Path "~"
if (Test-Path "$Path" -pathType container) {
Set-Location "$Path"
"📂$Path"
exit 0 # success
}
Set-Location "$Path"
"📂$Path"
exit 0 # success
throw "User's home folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -13,7 +13,7 @@
#>
try {
$Path = Resolve-Path "$PWD"
$Path = Resolve-Path -Path "$PWD"
"📂$Path"
exit 0 # success
} catch {