When I do git commit
, Git opens up a little Vim instance. Then I write in it and when I pres :wq
, Git saves that text and it becomes the commit message.
Is there any way to have such a workflow within julia? Not related to Git at all, just something to capture user input in a way that gives a bit more flexibility than readline()
.
Can you elaborate more on what you have in mind?
Like, at this point, my suggestion is to use ; vim
from the REPL. That is still “within” Julia to some extent, yea?
I want to be able to, after a prompt, write multiple lines, then when I close that small editor, julia saves the string of whatever I wrote as a string.
So accessing ; vim
would be fine if I could press :wq
when I’m done and julia saves that.
Something like this maybe?
path, io = mktemp()
close(io)
run(`vim $path`)
f = read(path, String)
rm(path)
So like a vim REPL mode? That could be interesting maybe
Wonderful! This is exactly what I am looking for.
You could write something to the file before calling close(io)
the user would see it when vim opens the file…but then you would need to remove it from f when you read the contents of the file.