mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-16 17:51:28 +01:00
Improve the cd-*.ps1 scripts
This commit is contained in:
parent
5706a11bdd
commit
7ab2795778
@ -13,7 +13,10 @@ cd-pics.ps1, go to the user's pictures folder
|
||||
cd-repos.ps1, go to the user's Git repositories folder
|
||||
cd-root.ps1, go to the root directory (C: on Windows)
|
||||
cd-scripts.ps1, go to the PowerShell Scripts folder
|
||||
cd-up.ps1, go one or multiple directories up
|
||||
cd-up.ps1, go one directory level up
|
||||
cd-up2.ps1, go two directory levels up
|
||||
cd-up3.ps1, go three directory levels up
|
||||
cd-up4.ps1, go four directory levels up
|
||||
cd-videos.ps1, go to the user's videos folder
|
||||
check-cpu-temp.ps1, checks the CPU temperature
|
||||
check-dns-resolution.ps1, checks the DNS resolution with frequently used domain names
|
||||
|
|
@ -99,7 +99,10 @@ Mega Collection of PowerShell Scripts
|
||||
* [cd-repos.ps1](Scripts/cd-repos.ps1) - go to the user's Git repositories folder
|
||||
* [cd-root.ps1](Scripts/cd-root.ps1) - go to the root directory (C:\ on Windows)
|
||||
* [cd-scripts.ps1](Scripts/cd-scripts.ps1) - go to the PowerShell Scripts folder
|
||||
* [cd-up.ps1](Scripts/cd-up.ps1) - go one or multiple directories up
|
||||
* [cd-up.ps1](Scripts/cd-up.ps1) - go one directory level up
|
||||
* [cd-up2.ps1](Scripts/cd-up2.ps1) - go two directory levels up
|
||||
* [cd-up3.ps1](Scripts/cd-up3.ps1) - go three directory levels up
|
||||
* [cd-up4.ps1](Scripts/cd-up4.ps1) - go four directory levels up
|
||||
* [cd-videos.ps1](Scripts/cd-videos.ps1) - go to the user's videos folder
|
||||
* [check-symlinks.ps1](Scripts/check-symlinks.ps1) - checks every symlink in the given directory tree
|
||||
* [check-xml-file.ps1](Scripts/check-xml-file.ps1) - checks the given XML file for validity
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-desktop.ps1
|
||||
.DESCRIPTION go to the user's desktop folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Desktop"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME/Desktop"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -6,12 +6,11 @@
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Documents"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME/Documents"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-downloads.ps1
|
||||
.DESCRIPTION go to the user's downloads folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Downloads"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME/Downloads"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-dropbox.ps1
|
||||
.DESCRIPTION go to the user's Dropbox folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Dropbox"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME/Dropbox"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-home.ps1
|
||||
.DESCRIPTION go to the user's home folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-music.ps1
|
||||
.DESCRIPTION go to the user's music folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Music"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME/Music"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-onedrive.ps1
|
||||
.DESCRIPTION go to the user's OneDrive folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/OneDrive"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME/OneDrive"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-pics.ps1
|
||||
.DESCRIPTION go to the user's pictures folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Pictures"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME/Pictures"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-repos.ps1
|
||||
.DESCRIPTION go to the user's Git repositories folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Repos"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME/Repos"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,21 +1,19 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-root.ps1
|
||||
.DESCRIPTION go to the root directory (C: on Windows)
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$TargetDir = resolve-path "/"
|
||||
} else {
|
||||
$TargetDir = resolve-path "C:/"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
if ($IsLinux) {
|
||||
$TargetDir = resolve-path "/"
|
||||
} else {
|
||||
$TargetDir = resolve-path "C:/"
|
||||
}
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-scripts.ps1
|
||||
.DESCRIPTION go to the PowerShell Scripts folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$PSScriptRoot"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$PSScriptRoot"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-up.ps1
|
||||
.DESCRIPTION go one directory up
|
||||
.DESCRIPTION go one directory level up
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path ".."
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path ".."
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-up2.ps1
|
||||
.DESCRIPTION go two directories up
|
||||
.DESCRIPTION go two directory levels up
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "../.."
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "../.."
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-up3.ps1
|
||||
.DESCRIPTION go three directories up
|
||||
.DESCRIPTION go three directory levels up
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "../../.."
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "../../.."
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-up4.ps1
|
||||
.DESCRIPTION go four directories up
|
||||
.DESCRIPTION go four directory levels up
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "../../../.."
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "../../../.."
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
@ -1,17 +1,15 @@
|
||||
#!/usr/bin/pwsh
|
||||
<#
|
||||
<#
|
||||
.SYNTAX cd-videos.ps1
|
||||
.DESCRIPTION go to the user's videos folder
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Videos"
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
$TargetDir = resolve-path "$HOME/Videos"
|
||||
if (-not(test-path "$TargetDir" -container leaf)) {
|
||||
write-warning "Sorry, directory 📂$TargetDir is missing"
|
||||
exit 1
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user