mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-21 15:33:15 +01:00
Updated the cd-*.ps1 scripts
This commit is contained in:
parent
6419712ff2
commit
bb01ef8cf5
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$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)"
|
||||
$path = Resolve-Path "~/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"
|
||||
"📂$Path"
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -14,16 +14,16 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "~/Desktop"
|
||||
$path = Resolve-Path "~/Desktop"
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('DesktopDirectory')
|
||||
$path = [Environment]::GetFolderPath('DesktopDirectory')
|
||||
}
|
||||
if (Test-Path "$Path" -pathType container) {
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
if (Test-Path "$path" -pathType container) {
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
}
|
||||
throw "User's desktop folder at 📂$Path doesn't exist (yet)"
|
||||
throw "User's desktop folder at 📂$path doesn't exist (yet)"
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "$HOME/Documents"
|
||||
$path = Resolve-Path "~/Documents"
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('MyDocuments')
|
||||
$path = [Environment]::GetFolderPath('MyDocuments')
|
||||
}
|
||||
if (-not(Test-Path "$Path" -pathType container)) {
|
||||
throw "Documents folder at 📂$Path doesn't exist (yet)"
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "Documents folder at 📂$path doesn't exist (yet)"
|
||||
}
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -14,16 +14,16 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "~/Downloads"
|
||||
$path = Resolve-Path "~/Downloads"
|
||||
} else {
|
||||
$Path = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path
|
||||
$path = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path
|
||||
}
|
||||
if (Test-Path "$Path" -pathType container) {
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
if (Test-Path "$path" -pathType container) {
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
}
|
||||
throw "User's downloads folder at 📂$Path doesn't exist (yet)"
|
||||
throw "User's downloads folder at 📂$path doesn't exist (yet)"
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
try {
|
||||
$path = Resolve-Path "~/Dropbox"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "No Dropbox folder at 📂$Path - is Dropbox installed?" }
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "No Dropbox folder at 📂$path - is Dropbox installed?" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
try {
|
||||
if ($IsLinx) {
|
||||
$Path = "/etc"
|
||||
$path = "/etc"
|
||||
} else {
|
||||
$Path = Resolve-Path "$env:WINDIR\System32\drivers\etc"
|
||||
$path = Resolve-Path "$env:WINDIR\System32\drivers\etc"
|
||||
}
|
||||
if (-not(Test-Path "$Path" -pathType container)) {
|
||||
throw "/etc directory at 📂$Path doesn't exist (yet)"
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "/etc directory at 📂$path doesn't exist (yet)"
|
||||
}
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$Path = [Environment]::GetFolderPath('Fonts')
|
||||
if (-not(Test-Path "$Path" -pathType container)) {
|
||||
throw "Fonts folder at 📂$Path doesn't exist (yet)"
|
||||
$path = [Environment]::GetFolderPath('Fonts')
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "Fonts folder at 📂$path doesn't exist (yet)"
|
||||
}
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -19,11 +19,11 @@ function GetLogsDir {
|
||||
}
|
||||
|
||||
try {
|
||||
$Path = GetLogsDir
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
$path = GetLogsDir
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
@ -14,16 +14,16 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "~/Music"
|
||||
$path = Resolve-Path "~/Music"
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('MyMusic')
|
||||
$path = [Environment]::GetFolderPath('MyMusic')
|
||||
}
|
||||
if (Test-Path "$Path" -pathType container) {
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
if (Test-Path "$path" -pathType container) {
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
}
|
||||
throw "User's music folder at 📂$Path doesn't exist (yet)"
|
||||
throw "User's music folder at 📂$path doesn't exist (yet)"
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
|
@ -14,13 +14,13 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "$HOME/Pictures"
|
||||
$path = Resolve-Path "~/Pictures"
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('MyPictures')
|
||||
$path = [Environment]::GetFolderPath('MyPictures')
|
||||
}
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Pictures folder at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Pictures folder at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -14,13 +14,13 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "~/Public"
|
||||
$path = Resolve-Path "~/Public"
|
||||
} else {
|
||||
$Path = Resolve-Path "~/../Public"
|
||||
$path = Resolve-Path "~/../Public"
|
||||
}
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Public folder at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Public folder at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -20,7 +20,7 @@ function GetCurrentUserSID { [CmdletBinding()] param()
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$path = "$HOME/.local/share/Trash/"
|
||||
$path = "~/.local/share/Trash/"
|
||||
} else {
|
||||
$path = "C:\`$Recycle.Bin\$(GetCurrentUserSID)"
|
||||
}
|
||||
|
@ -15,14 +15,14 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
if (Test-Path "$HOME/Repos/" -pathType Container) { # try short name
|
||||
$path = "$HOME/Repos/"
|
||||
} elseif (Test-Path "$HOME/repos/" -pathType Container) {
|
||||
$path = "$HOME/repos/"
|
||||
} elseif (Test-Path "$HOME/Repositories/" -pathType Container) { # try long name
|
||||
$path = "$HOME/Repositories/"
|
||||
} elseif (Test-Path "$HOME/source/repos/" -pathType Container) { # try Visual Studio default
|
||||
$path = "$HOME/source/repos/"
|
||||
if (Test-Path "~/Repos/" -pathType Container) { # try short name
|
||||
$path = "~/Repos/"
|
||||
} elseif (Test-Path "~/repos/" -pathType Container) {
|
||||
$path = "~/repos/"
|
||||
} elseif (Test-Path "~/Repositories/" -pathType Container) { # try long name
|
||||
$path = "~/Repositories/"
|
||||
} elseif (Test-Path "~/source/repos/" -pathType Container) { # try Visual Studio default
|
||||
$path = "~/source/repos/"
|
||||
} elseif (Test-Path "/Repos/" -pathType Container) {
|
||||
$path = "/Repos/"
|
||||
} else {
|
||||
|
@ -13,9 +13,9 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
if ($IsLinux) { $Path = "/" } else { $Path = "C:\" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
if ($IsLinux) { $path = "/" } else { $path = "C:\" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -14,23 +14,23 @@
|
||||
|
||||
function GetScreenshotsFolder {
|
||||
if ($IsLinux) {
|
||||
$Path = "$HOME/Pictures"
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Pictures folder at $Path doesn't exist (yet)" }
|
||||
if (Test-Path "$Path/Screenshots" -pathType container) { $Path = "$Path/Screenshots" }
|
||||
$path = "~/Pictures"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Pictures folder at $path doesn't exist (yet)" }
|
||||
if (Test-Path "$path/Screenshots" -pathType container) { $path = "$path/Screenshots" }
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('MyPictures')
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Pictures folder at $Path doesn't exist (yet)" }
|
||||
if (Test-Path "$Path\Screenshots" -pathType container) { $Path = "$Path\Screenshots" }
|
||||
$path = [Environment]::GetFolderPath('MyPictures')
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Pictures folder at $path doesn't exist (yet)" }
|
||||
if (Test-Path "$path\Screenshots" -pathType container) { $path = "$path\Screenshots" }
|
||||
}
|
||||
return $Path
|
||||
return $path
|
||||
}
|
||||
|
||||
try {
|
||||
$Path = GetScreenshotsFolder
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
$path = GetScreenshotsFolder
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ function GetTempDir {
|
||||
}
|
||||
|
||||
try {
|
||||
$Path = GetTempDir
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Temporary folder at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
$path = GetTempDir
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Temporary folder at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -14,13 +14,13 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "~/Templates"
|
||||
$path = Resolve-Path "~/Templates"
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('Templates')
|
||||
$path = [Environment]::GetFolderPath('Templates')
|
||||
}
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Templates folder at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Templates folder at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -20,7 +20,7 @@ function GetCurrentUserSID { [CmdletBinding()] param()
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$path = "$HOME/.local/share/Trash/"
|
||||
$path = "~/.local/share/Trash/"
|
||||
} else {
|
||||
$path = "C:\`$Recycle.Bin\$(GetCurrentUserSID)"
|
||||
}
|
||||
|
@ -13,10 +13,10 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$Path = Resolve-Path ".."
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Folder at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
$path = Resolve-Path ".."
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -13,10 +13,10 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$Path = Resolve-Path "../.."
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Folder at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
$path = Resolve-Path "../.."
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -13,10 +13,10 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$Path = Resolve-Path "../../.."
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Folder at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
$path = Resolve-Path "../../.."
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -13,10 +13,10 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$Path = Resolve-Path "../../../.."
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Folder at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
$path = Resolve-Path "../../../.."
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -13,10 +13,10 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$Path = Resolve-Path "$HOME/.."
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Users directory at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
$path = Resolve-Path "~/.."
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Users directory at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -14,13 +14,13 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "$HOME/Videos"
|
||||
$path = Resolve-Path "~/Videos"
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('MyVideos')
|
||||
$path = [Environment]::GetFolderPath('MyVideos')
|
||||
}
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Videos folder at 📂$Path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Videos folder at 📂$path doesn't exist (yet)" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -13,10 +13,10 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$Path = Resolve-Path "$env:WINDIR"
|
||||
if (-not(Test-Path "$Path" -pathType container)) { throw "Windows directory at 📂$Path doesn't exist" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
$path = Resolve-Path "$env:WINDIR"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Windows directory at 📂$path doesn't exist" }
|
||||
Set-Location "$path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user