Updated the manuals

This commit is contained in:
Markus Fleschutz
2024-03-27 17:36:59 +01:00
parent c5b5cb1c6e
commit aed2b7d940
610 changed files with 1754 additions and 1120 deletions

View File

@ -1,15 +1,15 @@
Script: *edit.ps1*
========================
This PowerShell script opens a text editor to edit the given file.
This PowerShell script opens a text editor with the given text file.
Parameters
----------
```powershell
PS> ./edit.ps1 [[-Filename] <String>] [<CommonParameters>]
PS> ./edit.ps1 [[-path] <String>] [<CommonParameters>]
-Filename <String>
Specifies the path to the filename
-path <String>
Specifies the path to the text file (will be queried if none given)
Required? false
Position? 1
@ -25,7 +25,7 @@ PS> ./edit.ps1 [[-Filename] <String>] [<CommonParameters>]
Example
-------
```powershell
PS> ./edit.ps1 C:\MyFile.txt
PS> ./edit.ps1 C:\MyDiary.txt
```
@ -42,29 +42,49 @@ Script Content
```powershell
<#
.SYNOPSIS
Opens an editor to edit a file
Opens a text editor
.DESCRIPTION
This PowerShell script opens a text editor to edit the given file.
.PARAMETER Filename
Specifies the path to the filename
This PowerShell script opens a text editor with the given text file.
.PARAMETER path
Specifies the path to the text file (will be queried if none given)
.EXAMPLE
PS> ./edit.ps1 C:\MyFile.txt
PS> ./edit.ps1 C:\MyDiary.txt
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$Filename = "")
param([string]$path = "")
function TryEditor { param([string]$editor, [string]$path)
try {
Write-Host -noNewline "$editor·"
& $editor "$path"
if ($lastExitCode -ne "0") {
"⚠️ Can't execute '$editor' - make sure it's installed and available"
exit 1
}
exit 0 # success
} catch {
return
}
}
try {
if ($IsLinux) {
& vi "$Filename"
if ($lastExitCode -ne "0") { throw "Can't execute 'vi' - make sure vi is installed and available" }
} else {
& notepad.exe "$Filename"
if ($lastExitCode -ne "0") { throw "Can't execute 'notepad.exe' - make sure notepad.exe is installed and available" }
}
if ($path -eq "" ) { $path = Read-Host "Enter the path to the text file" }
Write-Host -noNewline "Trying "
TryEditor "vim" $path
TryEditor "vi" $path
TryEditor "nano" $path
TryEditor "pico" $path
TryEditor "emacs" $path
TryEditor "notepad.exe" $path
TryEditor "wordpad.exe" $path
Write-Host ""
throw "No text editor found - use 'winget install' to install your favorite text editor."
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
@ -72,4 +92,4 @@ try {
}
```
*(generated by convert-ps2md.ps1 using the comment-based help of edit.ps1 as of 01/25/2024 13:58:38)*
*(generated by convert-ps2md.ps1 using the comment-based help of edit.ps1 as of 03/27/2024 17:36:26)*