Improve the cd-* scripts

This commit is contained in:
Markus Fleschutz
2021-10-19 08:24:17 +02:00
parent 32d2b76abb
commit e9bfd8cf10
19 changed files with 194 additions and 118 deletions

View File

@ -12,11 +12,15 @@
Author: Markus Fleschutz · License: CC0
#>
$TargetDir = resolve-path "$HOME/Desktop"
if (-not(test-path "$TargetDir" -pathType container)) {
write-warning "Sorry, the desktop folder at 📂$TargetDir does not exist (yet)"
try {
$TargetDir = resolve-path "$HOME/Desktop"
if (-not(test-path "$TargetDir" -pathType container)) {
throw "Desktop folder at 📂$TargetDir doesn't exist (yet)"
}
set-location "$TargetDir"
"📂$TargetDir"
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}
set-location "$TargetDir"
"📂$TargetDir"
exit 0 # success