LoranceChen
LoranceChen

Reputation: 2574

Is it possible to open a interactive vim process by Scala REPL shell command?

I'm exploring to use Scala REPL bridge to shell.It is mainly achieved by import sys.process._ package and I can use "ls" ! to execute shell.
Now, I want to use "vi" ! to open a interactive vi editor, it is really crazy but very exciting. After entering the cmd in REPL, the terminal opens a init vi canvas. Unfortunately, the terminal is not reading any input from my keyboard.

Is it possible to open a vi in REPL?

Upvotes: 3

Views: 410

Answers (1)

vitalii
vitalii

Reputation: 3365

from https://stackoverflow.com/a/29972867/1573825 (java solution):

import java.lang.{Process, ProcessBuilder}

 System.out.println("STARTING VI");
 val processBuilder = new ProcessBuilder("/usr/bin/vi")
 processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT)
 processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT)
 processBuilder.redirectInput(ProcessBuilder.Redirect.INHERIT)

 val p = processBuilder.start()
  // wait for termination.
  p.waitFor()
System.out.println("Exiting VI")

it doesn't even corrupt readline.

Upvotes: 1

Related Questions