PSReadLine
PSReadLine copied to clipboard
Consider using a default editor for the `ViEditVisually` function and / or issue a warning if the `$env:VISUAL` / `$env:EDITOR` value is invalid.
Prerequisites
- [X] Write a descriptive title.
Description of the new feature/enhancement
Currently, invoking the ViEditVisually function fails with no feedback other than a beep:
- if neither
$env:VISUALno$env:EDITORare defined. - If either variable exists, but contains an invalid value (notably including the case where options are part of the value - see https://github.com/PowerShell/PowerShell/issues/21525).
Consider modifying the behavior as follows, which would not only be more user-friendly in general, but also align with the behavior of other utilities, such as bash and git:
-
Use a default editor if neither
$env:VISUALno$env:EDITORare defined - and issue a warning if it cannot be found.- A possible candidate on Unix-like platform is
vi(this is whatgitdoes, though on some platforms it hasgeditas the compiled-in default) - On Windows, Notepad would do as a guaranteed-to-be-present option, though that would require invocation via
Start-Process -Wait(or equivalent) to ensure synchronous execution. Note that if a given machine has Git for Windows installed,nanoandvimare present (but not in$env:PATH), via$env:ProgramFiles\Git\usr\bin\nano.exeand$env:ProgramFiles\Git\usr\bin\vim.exe
- A possible candidate on Unix-like platform is
-
Issue a warning if the effective
$env:VISUAL/$env:EDITORvalue isn't invalid; ditto, should the decision be made not to implement use of a default editor and neither$env:VISUALnor$env:EDITORis defined.
Proposed technical implementation details (optional)
No response