diff --git a/solutions/rakudo/Configurable-REPL.md b/solutions/rakudo/Configurable-REPL.md new file mode 100644 index 0000000..b8a2f09 --- /dev/null +++ b/solutions/rakudo/Configurable-REPL.md @@ -0,0 +1,54 @@ +# Configurable REPL Prompt + +The default REPL for Rakudo is not configurable. + +# Proposed Solution + +Implement support for two environment variables: + +| Variable | Description | +|--|--| +| `RAKUDO_REPL_PROMPT` | the main prompt | +| `RAKUDO_REPL_PROMPT2` | the continuation prompt | + +Each which supports the following interpolations: + +| Backslash | Meaning | +|--|--| +| `\a` | alert / bell character | +| `\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` | +| `\t` | time - see below for more options | +| '\v' | `$*RAKU.compiler.version` | +| '\V' | `$*RAKU.gistt` | + +The escape character allows us to generate ANSI colors, e.g. + +`RAKUDO_REPL_PROMPT='[\e[0;31m\i\e[0m] >' + +Would generate a prompt similar to the default except the index would appear in red. + +## \t formatting + +The '\t' construct takes an optional set of '{}' 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 | + +# Future Development + +* Support for colors directly - needs a list of ANSI codes/colors in core. +* More strftime support - perhaps even invoking it directly instead of manually mapping. +* Support `RAKUDO_REPL_COMMAND` to support arbitrary code invocation + + +