thlorenz / replpad

Pipes content of files to a node repl whenever they change to enable a highly interactive coding experience.
http://thlorenz.github.com/replpad/
MIT License
213 stars 19 forks source link

support traversable command history across runs #16

Open hackergrrl opened 9 years ago

hackergrrl commented 9 years ago

It'd be really swell if I could run replpad, do a bunch of hacking, close it, and then, on a subsequent run, scroll back into my command history from that previous run (not unlike how my shell stores old commands in my e.g. .zsh_history file).

thlorenz commented 9 years ago

So basically we'd need to add a history file at ~/.config/replpad/history see paths.

To save we have two options:

a) append to history every time a command is entered (advantage history preserved if replpad crashes, disadvantage lots of writes) b) (over)write last x commands of history when replpad exits (advantage less writes, disadvantage latest history lost if replpad crashes)

In order to load it, we just have to read the file on start up and initialize the repl history with those commands.

How do we deal with multiline commands, like a function that spans three lines or so. Easiest is just to include these as well, but not sure how useful that is.

hackergrrl commented 9 years ago

There's also the option of writing in batches, either spatially (every 5 or 10 commands run) or temporally (every 1 or 5 minutes).

thlorenz commented 9 years ago

Yeah, but then we'd still have to write if you close in between an interval - maybe a bit too complex for what we need.

IMO just writing when you close replpad is fine. You should be using it with a file you write to anyways (that's that it's made for) so your code would still be there.