Open
Description
openedon Mar 27, 2024
Description
This RFC proposes adding support for displaying command history in the REPL. The behavior would be similar to that in IPython: https://ipython.readthedocs.io/en/stable/interactive/magics.html?highlight=magic#magic-history
Potential command signature:
history( [options] )
history( n[, options] )
history( start, stop[, options] )
with the ability to
- print a specific number of lines
n
- print a range of lines
[start, stop]
and options to
- specify a regex to filter commands to include
- specify a regex to filter commands to exclude
- filter based on whether a command succeeded or failed (e.g., a
success
option) - enabling displaying prompts in the output (i.e., the
-n
option in IPython) - control the prompt display (e.g., similar to the
p
option in IPython, but where one can provide, say,In [%d]:
to allow restarting the line numbers, which may be useful when printing REPL examples, etc) - include command results in the displayed output.
Related Issues
No.
Questions
- Presumably, we could have a separate command for saving history to a file. IMO, we should separate the concerns of displaying history from saving history to a file. Whatever APIs we provide can leverage common infrastructure, but they should probably be separate user APIs, with their own set of options and concerns.
- Including previous command results could be tricky. Maybe this is simple as moving the cursor up and then copying down, but I suspect that this could be more involved. And we cannot simply rely on inspecting the current values of workspace variables, as we'd want to capture the value of the variable at that point in history.
- Presumably, if a user clears their command history, they shouldn't be able to display the cleared commands. But what if a user clears their terminal screen? How do we effectively capture results/outputs at the time of execution?
Other
No.
Checklist
- I have read and understood the Code of Conduct.
- Searched for existing issues and pull requests.
- The issue name begins with
RFC:
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Issue or pull request for enhancing existing functionality.Issue involves or relates to JavaScript.Needs further discussion.Issue or pull request specific to the project REPL.Request for comments. Feature requests and proposed changes.Likely to be challenging but manageable.Normal priority concern or feature request.