mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-09 18:14:36 +02:00
Updated edit.ps1
This commit is contained in:
parent
8928a3bce4
commit
8cb81aadac
@ -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
|
||||
@ -39,4 +40,4 @@ TryEditor "wordpad.exe" $path
|
||||
Write-Host ""
|
||||
|
||||
"⚠️ Sorry, no text editor found. Please install your favorite one (e.g. by executing 'winget install helix.helix')."
|
||||
exit 1
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user