mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-06-26 15:01:56 +02:00
Updated cd-docs.ps1 and cd-ssh.ps1
This commit is contained in:
parent
74abe7ce45
commit
03d931f4e8
@ -1,11 +1,11 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the documents folder
|
Sets the working dir to the documents folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the documents folder.
|
This PowerShell script sets the current working directory to the documents folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-docs
|
PS> ./cd-docs.ps1
|
||||||
📂C:\Users\Markus\Documents entered (has 3 files and 0 folders)
|
📂C:\Users\Markus\Documents with 3 files and 0 folders entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -15,19 +15,19 @@
|
|||||||
try {
|
try {
|
||||||
if ($IsLinux -or $IsMacOS) {
|
if ($IsLinux -or $IsMacOS) {
|
||||||
if (-not(Test-Path "~/Documents" -pathType container)) {
|
if (-not(Test-Path "~/Documents" -pathType container)) {
|
||||||
throw "No 📂Documents folder in your home directory yet"
|
throw "No 'Documents' folder in your home directory yet"
|
||||||
}
|
}
|
||||||
$path = Resolve-Path "~/Documents"
|
$path = Resolve-Path "~/Documents"
|
||||||
} else {
|
} else {
|
||||||
$path = [Environment]::GetFolderPath('MyDocuments')
|
$path = [Environment]::GetFolderPath('MyDocuments')
|
||||||
if (-not(Test-Path "$path" -pathType container)) {
|
if (-not(Test-Path "$path" -pathType container)) {
|
||||||
throw "No documents folder at 📂$path yet"
|
throw "No documents folder at: $path yet"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$files = Get-ChildItem $path -attributes !Directory
|
$files = Get-ChildItem $path -attributes !Directory
|
||||||
$folders = Get-ChildItem $path -attributes Directory
|
$folders = Get-ChildItem $path -attributes Directory
|
||||||
"📂$path entered (has $($files.Count) files and $($folders.Count) folders)"
|
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ Error: $($Error[0])"
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the working directory to the SSH folder
|
Sets the working dir to the SSH folder
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script changes the working directory to the user's secure shell (SSH) folder.
|
This PowerShell script sets the current working directory to the user's secure shell (SSH) folder.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./cd-ssh.ps1
|
PS> ./cd-ssh.ps1
|
||||||
📂C:\Users\Markus\.ssh entered (has 4 files)
|
📂C:\Users\Markus\.ssh with 4 files entered.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -15,12 +15,12 @@
|
|||||||
try {
|
try {
|
||||||
$path = "~/.ssh"
|
$path = "~/.ssh"
|
||||||
if (-not(Test-Path "$path" -pathType container)) {
|
if (-not(Test-Path "$path" -pathType container)) {
|
||||||
throw "No secure shell (SSH) folder at $path"
|
throw "No '.ssh' folder in your home directory yet - Is SSH installed?"
|
||||||
}
|
}
|
||||||
$path = Resolve-Path "$path"
|
$path = Resolve-Path "$path"
|
||||||
Set-Location "$path"
|
Set-Location "$path"
|
||||||
$files = Get-ChildItem $path -attributes !Directory
|
$files = Get-ChildItem $path -attributes !Directory
|
||||||
"📂$path entered (has $($files.Count) files)"
|
"📂$path with $($files.Count) files entered."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ Error: $($Error[0])"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user