mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 16:03:22 +01:00
Update the cd-*.ps1 scripts and add cd-fonts.ps1
This commit is contained in:
parent
25fed61829
commit
3618087c25
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's autostart folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-autostart
|
||||
📂C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
|
||||
📂C:\Users\Joe\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Autostart folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$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 "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -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))"
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$DocsFolder = Resolve-Path "$HOME/Documents"
|
||||
$Path = Resolve-Path "$HOME/Documents"
|
||||
} else {
|
||||
$DocsFolder = [Environment]::GetFolderPath('MyDocuments')
|
||||
$Path = [Environment]::GetFolderPath('MyDocuments')
|
||||
}
|
||||
if (-not(Test-Path "$DocsFolder" -pathType container)) {
|
||||
throw "Documents folder at 📂$DocsFolder doesn't exist (yet)"
|
||||
if (-not(Test-Path "$Path" -pathType container)) {
|
||||
throw "Documents folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$DocsFolder"
|
||||
"📂$DocsFolder"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's downloads folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-downloads
|
||||
📂/home/markus/Downloads
|
||||
📂/home/Joe/Downloads
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Downloads"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Downloads folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "$HOME/Downloads"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Downloads folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's Dropbox folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-dropbox
|
||||
📂/home/markus/Dropbox
|
||||
📂/home/Joe/Dropbox
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Dropbox"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Dropbox folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "$HOME/Dropbox"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Dropbox folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
25
Scripts/cd-fonts.ps1
Executable file
25
Scripts/cd-fonts.ps1
Executable file
@ -0,0 +1,25 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the fonts folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the fonts folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-fonts
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
$Path = [Environment]::GetFolderPath('Fonts')
|
||||
if (-not(Test-Path "$Path" -pathType container)) {
|
||||
throw "Fonts folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's home directory.
|
||||
.EXAMPLE
|
||||
PS> ./cd-home
|
||||
📂/home/markus
|
||||
📂/home/Joe
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Home directory at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "$HOME"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Home directory at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's music folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-music
|
||||
📂/home/markus/Music
|
||||
📂/home/Joe/Music
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,16 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Music"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Music folder at 📂$TargetDir doesn't exist (yet)"
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "$HOME/Music"
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('MyMusic')
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
if (-not(Test-Path "$Path" -pathType container)) {
|
||||
throw "Music folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's OneDrive folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-onedrive
|
||||
📂/home/markus/OneDrive
|
||||
📂/home/Joe/OneDrive
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/OneDrive"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "OneDrive folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "$HOME/OneDrive"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "OneDrive folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's pictures folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-pics
|
||||
📂/home/markus/Pictures
|
||||
📂/home/Joe/Pictures
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,16 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Pictures"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Pictures folder at 📂$TargetDir doesn't exist (yet)"
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "$HOME/Pictures"
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('MyPictures')
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
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: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -19,12 +19,12 @@ function Get-CurrentUserSID { [CmdletBinding()] param()
|
||||
|
||||
|
||||
try {
|
||||
$TargetDir = 'C:\$Recycle.Bin\' + "$(Get-CurrentUserSID)"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Recycle bin folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = 'C:\$Recycle.Bin\' + "$(Get-CurrentUserSID)"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Recycle bin folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's Git repositories folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-repos
|
||||
📂/home/markus/Repos
|
||||
📂/home/Joe/Repos
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Repos"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Git repositories folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "$HOME/Repos"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Git repositories folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$TargetDir = resolve-path "/"
|
||||
$Path = resolve-path "/"
|
||||
} else {
|
||||
$TargetDir = resolve-path "C:\"
|
||||
$Path = resolve-path "C:\"
|
||||
}
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Root directory at 📂$TargetDir doesn't exist (yet)"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Root directory at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the PowerShell scripts folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-scripts
|
||||
📂/home/markus/PowerShell/Scripts
|
||||
📂/home/Joe/PowerShell/Scripts
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$PSScriptRoot"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "PowerShell scripts folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "$PSScriptRoot"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "PowerShell scripts folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's SSH folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-ssh
|
||||
📂/home/markus/.ssh
|
||||
📂/home/Joe/.ssh
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/.ssh"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "SSH folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "$HOME/.ssh"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "SSH folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the temporary folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-temp
|
||||
📂C:\Users\markus\AppData\Local\Temp
|
||||
📂C:\Users\Joe\AppData\Local\Temp
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -18,12 +18,12 @@ function GetTempDir {
|
||||
}
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path GetTempDir
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Temporary folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path GetTempDir
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Temporary folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -12,12 +12,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path ".."
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path ".."
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -12,12 +12,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "../.."
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "../.."
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -12,12 +12,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "../../.."
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "../../.."
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -12,12 +12,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "../../../.."
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Folder at 📂$TargetDir doesn't exist (yet)"
|
||||
$Path = resolve-path "../../../.."
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Folder at 📂$Path doesn't exist (yet)"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script changes the working directory to the user's videos folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-videos
|
||||
📂/home/markus/Videos
|
||||
📂/home/Joe/Videos
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,16 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Videos"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Videos folder at 📂$TargetDir doesn't exist (yet)"
|
||||
if ($IsLinux) {
|
||||
$Path = Resolve-Path "$HOME/Videos"
|
||||
} else {
|
||||
$Path = [Environment]::GetFolderPath('MyVideos')
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
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: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -13,12 +13,12 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$env:WINDIR"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Windows directory at 📂$TargetDir doesn't exist"
|
||||
$Path = resolve-path "$env:WINDIR"
|
||||
if (-not(test-path "$Path" -pathType container)) {
|
||||
throw "Windows directory at 📂$Path doesn't exist"
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
set-location "$Path"
|
||||
"📂$Path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -29,7 +29,7 @@ try {
|
||||
if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.Gateway' failed" }
|
||||
|
||||
$Hostname = $(hostname)
|
||||
& ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '[\"http://miami:5001\", \"http://localhost:3000\", \"http://127.0.0.1:5001\", \"https://webui.ipfs.io\"]'
|
||||
& ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '[\"http://paris:5001\", \"http://localhost:3000\", \"http://127.0.0.1:5001\", \"https://webui.ipfs.io\"]'
|
||||
if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Origin' failed" }
|
||||
|
||||
& ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '[\"PUT\", \"POST\"]'
|
||||
|
Loading…
Reference in New Issue
Block a user