mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-25 05:26:47 +01:00
Update cd-docs.ps1
This commit is contained in:
parent
6c03238aa9
commit
25fed61829
@ -1,11 +1,11 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the user's documents folder
|
||||
Sets the working directory to the documents folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the user's documents folder.
|
||||
This PowerShell script changes the working directory to the documents folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-docs
|
||||
📂/home/markus/Documents
|
||||
📂C:\Users\Joe\Documents
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -13,12 +13,16 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$TargetDir = resolve-path "$HOME/Documents"
|
||||
if (-not(test-path "$TargetDir" -pathType container)) {
|
||||
throw "Documents folder at 📂$TargetDir doesn't exist (yet)"
|
||||
if ($IsLinux) {
|
||||
$DocsFolder = Resolve-Path "$HOME/Documents"
|
||||
} else {
|
||||
$DocsFolder = [Environment]::GetFolderPath('MyDocuments')
|
||||
}
|
||||
set-location "$TargetDir"
|
||||
"📂$TargetDir"
|
||||
if (-not(Test-Path "$DocsFolder" -pathType container)) {
|
||||
throw "Documents folder at 📂$DocsFolder doesn't exist (yet)"
|
||||
}
|
||||
set-location "$DocsFolder"
|
||||
"📂$DocsFolder"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
Loading…
Reference in New Issue
Block a user