Skip to content
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

REPL history. #16

Closed
jdalton opened this issue Mar 17, 2016 · 4 comments
Closed

REPL history. #16

jdalton opened this issue Mar 17, 2016 · 4 comments

Comments

@jdalton
Copy link
Contributor

jdalton commented Mar 17, 2016

I was looking at trymodule and noticed it used repl.history
and thought it might be a good thing for n_ too.

I think some shells have a repl history baked in so not too sure if it's needed.

@borisdiakur
Copy link
Owner

trymodule looks cool. But I'm even more impressed by the colors.rainbow function. We should definitely include it into n_! I’ll send you a PR for lodash! 😁

Regarding the history feature: I’ve been thinking about it before because I was missing it myself in n_. You can save the repl session into a file manually using the command .save but that’s inconvenient.
The only aspect I don’t like about the repl.history module is that I’d have to add it as a dependency. I like n_ being dependent only on lodash. That’s why I was thinking of integrating session persistence “the native way”. Seems like I can load and save the last session using the following four lines of code:

// load the last session after server start
server.commands.load.action.apply(server, [path.join(process.env.HOME, 'n_repl_history')]);
// save the session on exit
process.on('exit', function () {
    server.commands.save.action.apply(server, [path.join(process.env.HOME, 'n_repl_history')]);
});

What do you think?

@jdalton
Copy link
Contributor Author

jdalton commented Mar 17, 2016

I don't mind the extra dep. The neat thing about a shared history package is that if others use it, like trymodule, then history persists across tools which is nice.

@borisdiakur
Copy link
Owner

If there just wasn’t that incompatibility issue tmpvar/repl.history#6 ...
Anyway, you're right. A shared history between different repls would be neat. This would however require all repls to use the same file path, which currently is not guaranteed by repl.history because the file path is an option.

@jdalton
Copy link
Contributor Author

jdalton commented Mar 18, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants