Updated edit.ps1

This commit is contained in:
Markus Fleschutz 2025-03-10 08:21:02 +01:00
parent 8928a3bce4
commit 8cb81aadac

View File

@ -18,7 +18,7 @@ param([string]$path = "")
function TryEditor { param([string]$editor, [string]$path)
try {
Write-Host "$editor/" -noNewline
Write-Host "$editor..." -noNewline
& $editor "$path"
if ($lastExitCode -ne 0) { "⚠️ Can't execute '$editor' - make sure it's installed and available"; exit 1 }
exit 0 # success
@ -26,7 +26,8 @@ function TryEditor { param([string]$editor, [string]$path)
}
if ($path -eq "" ) { $path = Read-Host "Enter the path to the text file" }
Write-Host "⏳ Editing 📄$path by trying " -noNewline
if (-not(Test-Path "$path" -pathType leaf)) { throw "Can't access file '$path'" }
Write-Host "⏳ Editing '$path' by executing " -noNewline
TryEditor "neovim" $path
TryEditor "vim" $path
TryEditor "vi" $path