Skip to content

Commit 4f0c48c

Browse files
committed
Add Solution for Configurable REPL
Fixes #459
1 parent add472a commit 4f0c48c

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

solutions/rakudo/Configurable-REPL.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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 | Default |
10+
|--|--|--|
11+
| `RAKUDO_REPL_PROMPT` | the main prompt | `[\i] > ` |
12+
| `RAKUDO_REPL_PROMPT2` | the continuation prompt | `* ` |
13+
14+
Each which supports the following interpolations:
15+
16+
| Sequence | Prompt Expansion |
17+
|--|--|
18+
| `\a` | alert / bell character |
19+
| `\c` | color - see below for options |
20+
| `\e` | escape character |
21+
| `\i` | index - the current iteration of the REPL, which can be referred to later as, e.g. `$*1` |
22+
| `\l` | `$*RAKU.version` |
23+
| `\L` | `$*RAKU.gist` |
24+
| `\n` | newline |
25+
| `\t` | time - see below for options |
26+
| `\v` | `$*RAKU.compiler.version` |
27+
| `\V` | `$*RAKU.gist` |
28+
29+
## \c formatting
30+
31+
Provide some common ANSI codes with short names. Defaults to `reset` if a bare `\c` is used,
32+
and multiple arguments can be separated with a `;`, e.g.
33+
34+
```
35+
\c{bold;red}
36+
```
37+
38+
### formatting
39+
40+
> reset, normal, bold, dim, italic, underline, blink, inverse, hiddne, strikethrough
41+
42+
### foreground colors
43+
44+
> black, red, green, yellow, blue, magenta, cyan, white, default
45+
46+
### background colors
47+
48+
> bg:black, bg:red, bg:green, bg:yellow, bg:blue, bg:magenta, bg:cyan, bg:white, bg:default
49+
50+
Not all escape sequences have aliases - you can always use
51+
`\e` to manually generate codes.
52+
53+
## \t formatting
54+
55+
The `\t` construct takes an optional `{}` containing a subset of `strftime` codes,
56+
defaulting to `%T` if a bare `\t` is used.
57+
58+
| Code | Value |
59+
|--|--|
60+
| `%T` | `%H:%M:%S` |
61+
| `%R` | `%H:%M` |
62+
| `%H` | 24-hour hours, 2 digits |
63+
| `%I` | 12-hour hours, 2 digits |
64+
| `%M` | minutes, 2 digits |
65+
| `%S` | seconds, 2 digits |
66+
67+
```
68+
RAKUDO_REPL_PROMPT='\t{%R} > '
69+
```
70+
71+
Would generate a prompt containing, e.g. `06:18 > `
72+
73+
# Future Development
74+
75+
* More strftime support - perhaps even invoking it directly instead of manually mapping.
76+
* Support `RAKUDO_REPL_COMMAND` to support arbitrary code invocation
77+
78+
79+

0 commit comments

Comments
 (0)