-
Notifications
You must be signed in to change notification settings - Fork 13
Configurable REPL prompt #460
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
Open
coke
wants to merge
1
commit into
main
Choose a base branch
from
coke/repl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Configurable REPL Prompt | ||
|
||
The default REPL for Rakudo is not configurable. | ||
|
||
# Proposed Solution | ||
|
||
Implement support for two environment variables: | ||
|
||
| Variable | Description | Default | | ||
|--|--|--| | ||
| `RAKUDO_REPL_PROMPT` | the main prompt | `[\i] > ` | | ||
| `RAKUDO_REPL_PROMPT2` | the continuation prompt | `* ` | | ||
|
||
Each which supports the following interpolations: | ||
|
||
| Sequence | Prompt Expansion | | ||
|--|--| | ||
| `\a` | alert / bell character | | ||
| `\c` | color - see below for options | | ||
| `\e` | escape character | | ||
| `\i` | index - the current iteration of the REPL, which can be referred to later as, e.g. `$*1` | | ||
| `\l` | `$*RAKU.version` | | ||
| `\L` | `$*RAKU.gist` | | ||
| `\n` | newline | | ||
| `\t` | time - see below for options | | ||
| `\v` | `$*RAKU.compiler.version` | | ||
| `\V` | `$*RAKU.gist` | | ||
|
||
## \c formatting | ||
|
||
Provide some common ANSI codes with short names. Defaults to `reset` if a bare `\c` is used, | ||
and multiple arguments can be separated with a `;`, e.g. | ||
|
||
``` | ||
\c{bold;red} | ||
``` | ||
|
||
### formatting | ||
|
||
> reset, normal, bold, dim, italic, underline, blink, inverse, hiddne, strikethrough | ||
|
||
### foreground colors | ||
|
||
> black, red, green, yellow, blue, magenta, cyan, white, default | ||
|
||
### background colors | ||
|
||
> bg:black, bg:red, bg:green, bg:yellow, bg:blue, bg:magenta, bg:cyan, bg:white, bg:default | ||
|
||
Not all escape sequences have aliases - you can always use | ||
`\e` to manually generate codes. | ||
|
||
## \t formatting | ||
|
||
The `\t` construct takes an optional `{}` containing a subset of `strftime` codes, | ||
defaulting to `%T` if a bare `\t` is used. | ||
|
||
| Code | Value | | ||
|--|--| | ||
| `%T` | `%H:%M:%S` | | ||
| `%R` | `%H:%M` | | ||
| `%H` | 24-hour hours, 2 digits | | ||
| `%I` | 12-hour hours, 2 digits | | ||
| `%M` | minutes, 2 digits | | ||
| `%S` | seconds, 2 digits | | ||
|
||
``` | ||
RAKUDO_REPL_PROMPT='\t{%R} > ' | ||
``` | ||
|
||
Would generate a prompt containing, e.g. `06:18 > ` | ||
|
||
# Future Development | ||
|
||
* More strftime support - perhaps even invoking it directly instead of manually mapping. | ||
* Support `RAKUDO_REPL_COMMAND` to support arbitrary code invocation | ||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
hidden
nothiddne