-
Notifications
You must be signed in to change notification settings - Fork 157
Persist REPL history #695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persist REPL history #695
Conversation
I'm a bit weary of writing a file to a user's home directory by default. |
I share that concern as well, as much as I'd like this to be default because it's really useful. Do you think this should be enabled with an environment variable like |
Maybe perhaps: if the file exists, use it and write to it, and if it doesn't, don't create it. This way a user would simply have to |
+1 on that idea ... obviously if the file exceeds 1MB or something, it should be truncated, yeah |
What do you think is a good amount of history to have and that shouldn't be exceeded? |
500? |
OK, updated to save history only if Because of the max line restriction, I changed the implementation to write history to file on exit instead on appending to file descriptor on each line entered. It was easier to do that way. |
2463f52
to
6c5bdb9
Compare
Most shells by default also add to history files on exit, so that should™ be okay. |
Personally I'd opt to write history by default now that there's the max line limit. Having to touch the file manually makes the feature hard to discover, but I'm happy to go with it as it is. |
What if I add an option to the command line, |
|
Sounds reasonable. That or maybe |
I like |
What should be the default behavior? I suggest the following:
|
should using |
Not sure if disabling history for a particular session is a very likely use case. |
Yes, that's why I think it should delete the file. Perhaps a warning and a (Y/n) before it deletes? |
f244167
to
b263a87
Compare
Is there anything I can do to help with this? |
I'd really like to see this in. (fixed merge conflicts) |
repl: write to .lsc_history only if it exists repl: retain 500 lines of history
@gkz will this be in? |
@@ -246,6 +250,8 @@ function output-filename filename, json | |||
# - __^C__: Cancel input if any. Quit otherwise. | |||
# - __??__: <https://github.com/joyent/node/blob/master/lib/readline.js> | |||
!function repl | |||
MAX-HISTORY-SIZE = 500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we want to move that up and use const
just to signify it's a constant. LGTM otherwise
thanks |
Makes LiveScript REPL history persist across sessions. Writes to
$HOME/.lsc_history
.I did not implement any upper limit on the history file size after which the history would be truncated. Will do that if necessary.
New to this project so let me know if the changes don't follow this project's general coding style.
Cheers.