diff --git a/scripts/edit.ps1 b/scripts/edit.ps1 index 21a69c5b..561b7fbd 100755 --- a/scripts/edit.ps1 +++ b/scripts/edit.ps1 @@ -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 \ No newline at end of file +exit 1