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

Rakudo REPL’s prompt not configurable #459

Open
msiism opened this issue Jan 9, 2025 · 5 comments
Open

Rakudo REPL’s prompt not configurable #459

msiism opened this issue Jan 9, 2025 · 5 comments
Assignees
Labels
rakudo Big changes to Rakudo

Comments

@msiism
Copy link

msiism commented Jan 9, 2025

The Rakudo REPL’s prompt consists of a result number in square brackets followed by a space character, a closing angle bracket, and another space character. Currently, there is no way to customize this prompt at runtime.

So, if, e.g., you are testing code examples in the REPL and then want to put the code and results into your notebook or share them with others, but without the result count included (because it doesn’t serve any meaningful purpose in your use case), you will have do extra work to remove it.

There are probably a couple of other good reasons to have a run-time configurable prompt, e. g., adding other bits of information or color to it in order to distinguish between several REPLs running in parallel.

@msiism msiism added the rakudo Big changes to Rakudo label Jan 9, 2025
@lizmat
Copy link
Collaborator

lizmat commented Jan 9, 2025

@coke

@msiism
Copy link
Author

msiism commented Jan 9, 2025

Initial proposal: The prompt should be configurable through an environment variable. On the Raku IRC channel, @coke suggested naming that variable RAKU_REPL_PROMPT, which seems a reasonable name to me.

It would also be quite practical to provide a set of pre-defined building blocks for the standard or most frequently needed prompt components, sort of like Bash does. A comfortable way to add color to the prompt that doesn’t require the user to construct cryptic and brittle ANSI escape sequences would also be helpful.

@coke coke self-assigned this Jan 9, 2025
@lizmat
Copy link
Collaborator

lizmat commented Jan 9, 2025

The Prompt module may also be of interest

@coke
Copy link
Contributor

coke commented Jan 9, 2025

Started a POC in rakudo's repo on coke/ps1 - Will play for a bit to see what's feasible and followup here with a proposal

@coke
Copy link
Contributor

coke commented Jan 10, 2025

I have a naive version at https://github.com/rakudo/rakudo/blob/coke/ps1/src/core.c/REPL.rakumod#L411-L422 with simplistic backslash substitution - \e is supported, so we can do manual escape sequences for coloring/bold; there is RAKUDO_REPL_PROMPT for the main prompt and RAKUDO_REPL_PROMPT2 for the secondary (both support all substitutions).
Screenshot 2025-01-10 at 12 05 52 PM

coke added a commit that referenced this issue Jan 10, 2025
coke added a commit that referenced this issue Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rakudo Big changes to Rakudo
Projects
None yet
Development

No branches or pull requests

3 participants