-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #459
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 | ||
|
||
|
||
|