Update cd-downloads.ps1

This commit is contained in:
Markus Fleschutz 2022-02-25 13:20:48 +01:00
parent 4de937934d
commit 89194a0286

View File

@ -5,7 +5,7 @@
This PowerShell script changes the working directory to the user's downloads folder. This PowerShell script changes the working directory to the user's downloads folder.
.EXAMPLE .EXAMPLE
PS> ./cd-downloads PS> ./cd-downloads
📂/home/Joe/Downloads 📂C:\Users\Joe\Downloads
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -13,11 +13,15 @@
#> #>
try { try {
$Path = resolve-path "$HOME/Downloads" if ($IsLinux) {
if (-not(test-path "$Path" -pathType container)) { $Path = Resolve-Path "$HOME/Downloads"
} else {
$Path = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path
}
if (-not(Test-Path "$Path" -pathType container)) {
throw "Downloads folder at 📂$Path doesn't exist (yet)" throw "Downloads folder at 📂$Path doesn't exist (yet)"
} }
set-location "$Path" Set-Location "$Path"
"📂$Path" "📂$Path"
exit 0 # success exit 0 # success
} catch { } catch {