Update the cd-*.ps1 scripts

This commit is contained in:
Markus Fleschutz 2022-05-04 11:50:18 +02:00
parent 1803b09fad
commit 45cd3e0876
22 changed files with 83 additions and 78 deletions

View File

@ -5,19 +5,19 @@
This PowerShell script changes the working directory to the user's autostart folder.
.EXAMPLE
PS> ./cd-autostart
📂C:\Users\Joe\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
📂C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "$HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "$HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
if (-not(Test-Path "$Path" -pathType container)) {
throw "Autostart folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,23 +5,23 @@
This PowerShell script changes the working directory to the user's desktop folder.
.EXAMPLE
PS> ./cd-desktop
📂/home/Joe/Desktop
📂/home/Markus/Desktop
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
$Path = resolve-path "$HOME/Desktop"
$Path = Resolve-Path "$HOME/Desktop"
} else {
$Path = [Environment]::GetFolderPath('DesktopDirectory')
}
if (-not(Test-Path "$Path" -pathType container)) {
throw "Desktop folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,11 +5,11 @@
This PowerShell script changes the working directory to the documents folder.
.EXAMPLE
PS> ./cd-docs
📂C:\Users\Joe\Documents
📂C:\Users\Markus\Documents
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
@ -21,7 +21,7 @@ try {
if (-not(Test-Path "$Path" -pathType container)) {
throw "Documents folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,11 +5,11 @@
This PowerShell script changes the working directory to the user's downloads folder.
.EXAMPLE
PS> ./cd-downloads
📂C:\Users\Joe\Downloads
📂C:\Users\Markus\Downloads
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {

View File

@ -5,11 +5,11 @@
This PowerShell script changes the working directory to the user's Dropbox folder.
.EXAMPLE
PS> ./cd-dropbox
📂/home/Joe/Dropbox
📂/home/Markus/Dropbox
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {

View File

@ -9,7 +9,7 @@
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
@ -17,7 +17,7 @@ try {
if (-not(Test-Path "$Path" -pathType container)) {
throw "Fonts folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,19 +5,19 @@
This PowerShell script changes the working directory to the user's home directory.
.EXAMPLE
PS> ./cd-home
📂/home/Joe
📂/home/Markus
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "$HOME"
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "$HOME"
if (-not(Test-Path "$Path" -pathType container)) {
throw "Home directory at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,11 +5,11 @@
This PowerShell script changes the working directory to the user's music folder.
.EXAMPLE
PS> ./cd-music
📂/home/Joe/Music
📂/home/Markus/Music
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
@ -21,7 +21,7 @@ try {
if (-not(Test-Path "$Path" -pathType container)) {
throw "Music folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,19 +5,19 @@
This PowerShell script changes the working directory to the user's OneDrive folder.
.EXAMPLE
PS> ./cd-onedrive
📂/home/Joe/OneDrive
📂/home/Markus/OneDrive
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "$HOME/OneDrive"
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "$HOME/OneDrive"
if (-not(Test-Path "$Path" -pathType container)) {
throw "OneDrive folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,11 +5,11 @@
This PowerShell script changes the working directory to the user's pictures folder.
.EXAMPLE
PS> ./cd-pics
📂/home/Joe/Pictures
📂/home/Markus/Pictures
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {

View File

@ -9,7 +9,7 @@
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
function GetCurrentUserSID { [CmdletBinding()] param()
@ -20,10 +20,10 @@ function GetCurrentUserSID { [CmdletBinding()] param()
try {
$Path = 'C:\$Recycle.Bin\' + "$(GetCurrentUserSID)"
if (-not(test-path "$Path" -pathType container)) {
if (-not(Test-Path "$Path" -pathType container)) {
throw "Recycle bin folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,19 +5,19 @@
This PowerShell script changes the working directory to the user's Git repositories folder.
.EXAMPLE
PS> ./cd-repos
📂/home/Joe/Repos
📂/home/Markus/Repos
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "$HOME/Repos"
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "$HOME/Repos"
if (-not(Test-Path "$Path" -pathType container)) {
throw "Git repositories folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,15 +5,16 @@
This PowerShell script changes the current working directory to the root directory (C:\ on Windows).
.EXAMPLE
PS> ./cd-root
📂C:\
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) { $Path = "/" } else { $Path = "C:\" }
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,19 +5,19 @@
This PowerShell script changes the working directory to the PowerShell scripts folder.
.EXAMPLE
PS> ./cd-scripts
📂/home/Joe/PowerShell/Scripts
📂/home/Markus/PowerShell/Scripts
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "$PSScriptRoot"
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "$PSScriptRoot"
if (-not(Test-Path "$Path" -pathType container)) {
throw "PowerShell scripts folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,19 +5,19 @@
This PowerShell script changes the working directory to the user's SSH folder.
.EXAMPLE
PS> ./cd-ssh
📂/home/Joe/.ssh
📂/home/Markus/.ssh
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "$HOME/.ssh"
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "$HOME/.ssh"
if (-not(Test-Path "$Path" -pathType container)) {
throw "SSH folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,11 +5,11 @@
This PowerShell script changes the working directory to the temporary folder.
.EXAMPLE
PS> ./cd-temp
📂C:\Users\Joe\AppData\Local\Temp
📂C:\Users\Markus\AppData\Local\Temp
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
function GetTempDir {

View File

@ -5,18 +5,19 @@
This PowerShell script changes the working directory to one directory level up.
.EXAMPLE
PS> .\cd-up
📂C:\Users
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path ".."
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path ".."
if (-not(Test-Path "$Path" -pathType container)) {
throw "Folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,18 +5,19 @@
This PowerShell script changes the working directory to two directory level up.
.EXAMPLE
PS> ./cd-up2
📂C:\
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "../.."
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "../.."
if (-not(Test-Path "$Path" -pathType container)) {
throw "Folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,18 +5,19 @@
This PowerShell script changes the working directory to three directory levels up.
.EXAMPLE
PS> ./cd-up3
📂C:\
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "../../.."
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "../../.."
if (-not(Test-Path "$Path" -pathType container)) {
throw "Folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,18 +5,19 @@
This PowerShell script changes the working directory to four directory levels up.
.EXAMPLE
PS> ./cd-up4
📂C:\
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "../../../.."
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "../../../.."
if (-not(Test-Path "$Path" -pathType container)) {
throw "Folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -5,11 +5,11 @@
This PowerShell script changes the working directory to the user's videos folder.
.EXAMPLE
PS> ./cd-videos
📂/home/Joe/Videos
📂C:\Users\Markus\Videos
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
@ -21,7 +21,7 @@ try {
if (-not(Test-Path "$Path" -pathType container)) {
throw "Videos folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {

View File

@ -9,15 +9,15 @@
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
Author: Markus Fleschutz | License: CC0
#>
try {
$Path = resolve-path "$env:WINDIR"
if (-not(test-path "$Path" -pathType container)) {
$Path = Resolve-Path "$env:WINDIR"
if (-not(Test-Path "$Path" -pathType container)) {
throw "Windows directory at 📂$Path doesn't exist"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {