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
|
||||
Sets the working directory to the documents folder
|
||||
Sets the working dir to the documents folder
|
||||
.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
|
||||
PS> ./cd-docs
|
||||
📂C:\Users\Markus\Documents entered (has 3 files and 0 folders)
|
||||
PS> ./cd-docs.ps1
|
||||
📂C:\Users\Markus\Documents with 3 files and 0 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -15,19 +15,19 @@
|
||||
try {
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
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"
|
||||
} else {
|
||||
$path = [Environment]::GetFolderPath('MyDocuments')
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "No documents folder at 📂$path yet"
|
||||
throw "No documents folder at: $path yet"
|
||||
}
|
||||
}
|
||||
Set-Location "$path"
|
||||
$files = 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
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
|
@ -1,11 +1,11 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the SSH folder
|
||||
Sets the working dir to the SSH folder
|
||||
.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
|
||||
PS> ./cd-ssh.ps1
|
||||
📂C:\Users\Markus\.ssh entered (has 4 files)
|
||||
📂C:\Users\Markus\.ssh with 4 files entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -15,12 +15,12 @@
|
||||
try {
|
||||
$path = "~/.ssh"
|
||||
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"
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
"📂$path entered (has $($files.Count) files)"
|
||||
"📂$path with $($files.Count) files entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
|
Loading…
x
Reference in New Issue
Block a user