showEditor function

void showEditor(
  1. String path
)

Launches the systems default cli editor on Linux and MacOS using the EDITOR environment variable.

On Windows we launch notepad.

If the EDITOR environment variable isn't found then we check for the VISUAL environment variable. If neither is found we use vi.

EXPERIMENTAL

Implementation

void showEditor(String path) {
  String? editor;
  if (Settings().isWindows) {
    editor = 'notepad.exe';
  } else {
    editor = env['EDITOR'];
    editor ??= env['VISIBLE'];
    editor ??= 'vi';
  }

  // https://github.com/git/git/blob/master/editor.c
  '$editor $path'.start(terminal: true);
}