Update the cd-*.ps1 scripts and add cd-fonts.ps1

This commit is contained in:
Markus Fleschutz
2022-02-25 13:08:25 +01:00
parent 25fed61829
commit 3618087c25
23 changed files with 162 additions and 121 deletions

View File

@ -5,7 +5,7 @@
This PowerShell script changes the working directory to the user's desktop folder.
.EXAMPLE
PS> ./cd-desktop
📂/home/markus/Desktop
📂/home/Joe/Desktop
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -13,12 +13,16 @@
#>
try {
$TargetDir = resolve-path "$HOME/Desktop"
if (-not(test-path "$TargetDir" -pathType container)) {
throw "Desktop folder at 📂$TargetDir doesn't exist (yet)"
if ($IsLinux) {
$Path = resolve-path "$HOME/Desktop"
} else {
$Path = [Environment]::GetFolderPath('DesktopDirectory')
}
set-location "$TargetDir"
"📂$TargetDir"
if (-not(Test-Path "$Path" -pathType container)) {
throw "Desktop folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
"📂$Path"
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"