mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
Improve the cd-* scripts
This commit is contained in:
@ -12,11 +12,15 @@
|
||||
Author: Markus Fleschutz · License: CC0
|
||||
#>
|
||||
|
||||
$TargetDir = resolve-path "$HOME"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
write-warning "Sorry, the user's home directory at 📂$TargetDir does not exist (yet)"
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Home directory 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
|
||||
|
Reference in New Issue
Block a user