mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-29 05:09:05 +02:00
Renamed to remember.ps1
This commit is contained in:
parent
32347ab51d
commit
e52a77bba2
@ -1,36 +0,0 @@
|
|||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Adds a memo text
|
|
||||||
.DESCRIPTION
|
|
||||||
This PowerShell script saves the given memo text to Memos.csv in your home folder.
|
|
||||||
.PARAMETER text
|
|
||||||
Specifies the text to memorize
|
|
||||||
.EXAMPLE
|
|
||||||
PS> ./add-memo.ps1 "Buy apples"
|
|
||||||
✔️ saved to 📄/home/markus/Memos.csv
|
|
||||||
.LINK
|
|
||||||
https://github.com/fleschutz/PowerShell
|
|
||||||
.NOTES
|
|
||||||
Author: Markus Fleschutz | License: CC0
|
|
||||||
#>
|
|
||||||
|
|
||||||
param([string]$text = "")
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ($text -eq "" ) { $text = Read-Host "Enter the text to memorize" }
|
|
||||||
|
|
||||||
$Path = "~/Memos.csv"
|
|
||||||
$Time = Get-Date -format FileDateTimeUniversal
|
|
||||||
$Line = "$Time,$text"
|
|
||||||
|
|
||||||
if (-not(Test-Path "$Path" -pathType leaf)) {
|
|
||||||
Write-Output "TIME,TEXT" > "$Path"
|
|
||||||
}
|
|
||||||
Write-Output $Line >> "$Path"
|
|
||||||
|
|
||||||
"✔️ saved to 📄$Path"
|
|
||||||
exit 0 # success
|
|
||||||
} catch {
|
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
||||||
exit 1
|
|
||||||
}
|
|
38
scripts/remember.ps1
Executable file
38
scripts/remember.ps1
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Remembers a text
|
||||||
|
.DESCRIPTION
|
||||||
|
This PowerShell script saves the given text to Memos.csv in your home folder.
|
||||||
|
.PARAMETER text1
|
||||||
|
Specifies the text to memorize
|
||||||
|
.EXAMPLE
|
||||||
|
PS> ./remember.ps1 "Buy apples"
|
||||||
|
✔️ Saved to /home/Markus/Memos.csv in 0s.
|
||||||
|
.LINK
|
||||||
|
https://github.com/fleschutz/PowerShell
|
||||||
|
.NOTES
|
||||||
|
Author: Markus Fleschutz | License: CC0
|
||||||
|
#>
|
||||||
|
|
||||||
|
param([string]$text1 = "", [string]$text2 = "", [string]$text3 = "")
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($text1 -eq "") { $text1 = Read-Host "Enter what needs to be remembered" }
|
||||||
|
|
||||||
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
$timestamp = Get-Date -format FileDateTimeUniversal
|
||||||
|
$path = "~/Memos.csv"
|
||||||
|
|
||||||
|
if (-not(Test-Path "$path" -pathType leaf)) {
|
||||||
|
Write-Output "TIME,TEXT" > $path
|
||||||
|
}
|
||||||
|
Write-Output "$($timestamp),$text1 $text2 $text3" >> $path
|
||||||
|
$path = Resolve-Path $path
|
||||||
|
|
||||||
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
|
"✔️ Saved to $path in $($elapsed)s."
|
||||||
|
exit 0 # success
|
||||||
|
} catch {
|
||||||
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
exit 1
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user