mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-09 01:38:26 +02: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.
|
This PowerShell script changes the working directory to the user's autostart folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-autostart
|
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
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
|
$Path = resolve-path "$HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Autostart folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Autostart folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's desktop folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-desktop
|
PS> ./cd-desktop
|
||||||
📂/home/markus/Desktop
|
📂/home/Joe/Desktop
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,16 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/Desktop"
|
if ($IsLinux) {
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
$Path = resolve-path "$HOME/Desktop"
|
||||||
throw "Desktop folder at 📂$TargetDir doesn't exist (yet)"
|
} else {
|
||||||
|
$Path = [Environment]::GetFolderPath('DesktopDirectory')
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
if (-not(Test-Path "$Path" -pathType container)) {
|
||||||
"📂$TargetDir"
|
throw "Desktop folder at 📂$Path doesn't exist (yet)"
|
||||||
|
}
|
||||||
|
set-location "$Path"
|
||||||
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -14,15 +14,15 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
$DocsFolder = Resolve-Path "$HOME/Documents"
|
$Path = Resolve-Path "$HOME/Documents"
|
||||||
} else {
|
} else {
|
||||||
$DocsFolder = [Environment]::GetFolderPath('MyDocuments')
|
$Path = [Environment]::GetFolderPath('MyDocuments')
|
||||||
}
|
}
|
||||||
if (-not(Test-Path "$DocsFolder" -pathType container)) {
|
if (-not(Test-Path "$Path" -pathType container)) {
|
||||||
throw "Documents folder at 📂$DocsFolder doesn't exist (yet)"
|
throw "Documents folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$DocsFolder"
|
set-location "$Path"
|
||||||
"📂$DocsFolder"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's downloads folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-downloads
|
PS> ./cd-downloads
|
||||||
📂/home/markus/Downloads
|
📂/home/Joe/Downloads
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/Downloads"
|
$Path = resolve-path "$HOME/Downloads"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Downloads folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Downloads folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's Dropbox folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-dropbox
|
PS> ./cd-dropbox
|
||||||
📂/home/markus/Dropbox
|
📂/home/Joe/Dropbox
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/Dropbox"
|
$Path = resolve-path "$HOME/Dropbox"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Dropbox folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Dropbox folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's home directory.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-home
|
PS> ./cd-home
|
||||||
📂/home/markus
|
📂/home/Joe
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME"
|
$Path = resolve-path "$HOME"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Home directory at 📂$TargetDir doesn't exist (yet)"
|
throw "Home directory at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's music folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-music
|
PS> ./cd-music
|
||||||
📂/home/markus/Music
|
📂/home/Joe/Music
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,16 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/Music"
|
if ($IsLinux) {
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
$Path = Resolve-Path "$HOME/Music"
|
||||||
throw "Music folder at 📂$TargetDir doesn't exist (yet)"
|
} else {
|
||||||
|
$Path = [Environment]::GetFolderPath('MyMusic')
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
if (-not(Test-Path "$Path" -pathType container)) {
|
||||||
"📂$TargetDir"
|
throw "Music folder at 📂$Path doesn't exist (yet)"
|
||||||
|
}
|
||||||
|
set-location "$Path"
|
||||||
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's OneDrive folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-onedrive
|
PS> ./cd-onedrive
|
||||||
📂/home/markus/OneDrive
|
📂/home/Joe/OneDrive
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/OneDrive"
|
$Path = resolve-path "$HOME/OneDrive"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "OneDrive folder at 📂$TargetDir doesn't exist (yet)"
|
throw "OneDrive folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's pictures folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-pics
|
PS> ./cd-pics
|
||||||
📂/home/markus/Pictures
|
📂/home/Joe/Pictures
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,16 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/Pictures"
|
if ($IsLinux) {
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
$Path = Resolve-Path "$HOME/Pictures"
|
||||||
throw "Pictures folder at 📂$TargetDir doesn't exist (yet)"
|
} else {
|
||||||
|
$Path = [Environment]::GetFolderPath('MyPictures')
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
if (-not(Test-Path "$Path" -pathType container)) {
|
||||||
"📂$TargetDir"
|
throw "Pictures folder at 📂$Path doesn't exist (yet)"
|
||||||
|
}
|
||||||
|
Set-Location "$Path"
|
||||||
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -19,12 +19,12 @@ function Get-CurrentUserSID { [CmdletBinding()] param()
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = 'C:\$Recycle.Bin\' + "$(Get-CurrentUserSID)"
|
$Path = 'C:\$Recycle.Bin\' + "$(Get-CurrentUserSID)"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Recycle bin folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Recycle bin folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's Git repositories folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-repos
|
PS> ./cd-repos
|
||||||
📂/home/markus/Repos
|
📂/home/Joe/Repos
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/Repos"
|
$Path = resolve-path "$HOME/Repos"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Git repositories folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Git repositories folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -14,15 +14,15 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
$TargetDir = resolve-path "/"
|
$Path = resolve-path "/"
|
||||||
} else {
|
} else {
|
||||||
$TargetDir = resolve-path "C:\"
|
$Path = resolve-path "C:\"
|
||||||
}
|
}
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Root directory at 📂$TargetDir doesn't exist (yet)"
|
throw "Root directory at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
This PowerShell script changes the working directory to the PowerShell scripts folder.
|
This PowerShell script changes the working directory to the PowerShell scripts folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-scripts
|
PS> ./cd-scripts
|
||||||
📂/home/markus/PowerShell/Scripts
|
📂/home/Joe/PowerShell/Scripts
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$PSScriptRoot"
|
$Path = resolve-path "$PSScriptRoot"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "PowerShell scripts folder at 📂$TargetDir doesn't exist (yet)"
|
throw "PowerShell scripts folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's SSH folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-ssh
|
PS> ./cd-ssh
|
||||||
📂/home/markus/.ssh
|
📂/home/Joe/.ssh
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/.ssh"
|
$Path = resolve-path "$HOME/.ssh"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "SSH folder at 📂$TargetDir doesn't exist (yet)"
|
throw "SSH folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
This PowerShell script changes the working directory to the temporary folder.
|
This PowerShell script changes the working directory to the temporary folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-temp
|
PS> ./cd-temp
|
||||||
📂C:\Users\markus\AppData\Local\Temp
|
📂C:\Users\Joe\AppData\Local\Temp
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -18,12 +18,12 @@ function GetTempDir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path GetTempDir
|
$Path = resolve-path GetTempDir
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Temporary folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Temporary folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path ".."
|
$Path = resolve-path ".."
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "../.."
|
$Path = resolve-path "../.."
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "../../.."
|
$Path = resolve-path "../../.."
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "../../../.."
|
$Path = resolve-path "../../../.."
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Folder at 📂$TargetDir doesn't exist (yet)"
|
throw "Folder at 📂$Path doesn't exist (yet)"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ 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.
|
This PowerShell script changes the working directory to the user's videos folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-videos
|
PS> ./cd-videos
|
||||||
📂/home/markus/Videos
|
📂/home/Joe/Videos
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,12 +13,16 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$HOME/Videos"
|
if ($IsLinux) {
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
$Path = Resolve-Path "$HOME/Videos"
|
||||||
throw "Videos folder at 📂$TargetDir doesn't exist (yet)"
|
} else {
|
||||||
|
$Path = [Environment]::GetFolderPath('MyVideos')
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
if (-not(Test-Path "$Path" -pathType container)) {
|
||||||
"📂$TargetDir"
|
throw "Videos folder at 📂$Path doesn't exist (yet)"
|
||||||
|
}
|
||||||
|
set-location "$Path"
|
||||||
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$TargetDir = resolve-path "$env:WINDIR"
|
$Path = resolve-path "$env:WINDIR"
|
||||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
if (-not(test-path "$Path" -pathType container)) {
|
||||||
throw "Windows directory at 📂$TargetDir doesn't exist"
|
throw "Windows directory at 📂$Path doesn't exist"
|
||||||
}
|
}
|
||||||
set-location "$TargetDir"
|
set-location "$Path"
|
||||||
"📂$TargetDir"
|
"📂$Path"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||||
|
@ -29,7 +29,7 @@ try {
|
|||||||
if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.Gateway' failed" }
|
if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.Gateway' failed" }
|
||||||
|
|
||||||
$Hostname = $(hostname)
|
$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" }
|
if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Origin' failed" }
|
||||||
|
|
||||||
& ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '[\"PUT\", \"POST\"]'
|
& ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '[\"PUT\", \"POST\"]'
|
||||||
|
Loading…
Reference in New Issue
Block a user