Skip to content

Commit

Permalink
Add Solution for #459
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Jan 10, 2025
1 parent e1a76d0 commit d3a10c7
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions solutions/rakudo/Configurable-REPL.md
Original file line number Diff line number Diff line change
@@ -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



0 comments on commit d3a10c7

Please sign in to comment.