|
| 1 | +# Configurable REPL Prompt |
| 2 | + |
| 3 | +The default REPL for Rakudo is not configurable. |
| 4 | + |
| 5 | +# Proposed Solution |
| 6 | + |
| 7 | +Implement support for two environment variables: |
| 8 | + |
| 9 | +| Variable | Description | |
| 10 | +|--|--| |
| 11 | +| `RAKUDO_REPL_PROMPT` | the main prompt | |
| 12 | +| `RAKUDO_REPL_PROMPT2` | the continuation prompt | |
| 13 | + |
| 14 | +Each which supports the following interpolations: |
| 15 | + |
| 16 | +| Backslash | Meaning | |
| 17 | +|--|--| |
| 18 | +| `\a` | alert / bell character | |
| 19 | +| `\e` | escape character | |
| 20 | +| `\i` | index - the current iteration of the REPL, which can be referred to later as, e.g. `$*1` | |
| 21 | +| '\l' | `$*RAKU.version` | |
| 22 | +| '\L' | `$*RAKU..gist` | |
| 23 | +| `\t` | time - see below for more options | |
| 24 | +| '\v' | `$*RAKU.compiler.version` | |
| 25 | +| '\V' | `$*RAKU.gistt` | |
| 26 | + |
| 27 | +The escape character allows us to generate ANSI colors, e.g. |
| 28 | + |
| 29 | +`RAKUDO_REPL_PROMPT='[\e[0;31m\i\e[0m] >' |
| 30 | + |
| 31 | +Would generate a prompt similar to the default except the index would appear in red. |
| 32 | + |
| 33 | +## \t formatting |
| 34 | + |
| 35 | +The '\t' construct takes an optional set of '{}' containing a subset of `strftime` codes, |
| 36 | +defaulting to %T if a bare `\t` is used. |
| 37 | + |
| 38 | +| Code | Value | |
| 39 | +|--|--| |
| 40 | +| `%T` | `%H:%M:%S` | |
| 41 | +| `%R` | `%H:%M` | |
| 42 | +| `%H` | 24-Hour hours, 2 digits | |
| 43 | +| `%I` | 12-hour hours, 2 digits | |
| 44 | +| `%M` | minutes, 2 digits | |
| 45 | +| `%S` | seconds, 2 digits | |
| 46 | + |
| 47 | +# Future Development |
| 48 | + |
| 49 | +* Support for colors directly - needs a list of ANSI codes/colors in core. |
| 50 | +* More strftime support - perhaps even invoking it directly instead of manually mapping. |
| 51 | +* Support `RAKUDO_REPL_COMMAND` to support arbitrary code invocation |
| 52 | + |
| 53 | + |
| 54 | + |
0 commit comments