Skip to content

REPL and History

Chloë Strainge edited this page Oct 15, 2026 · 2 revisions

The REPL and persistent history

The REPL keeps language state across submitted inputs: variables, functions, methods, aliases, and module scopes remain available until the process exits. A newly installed binary takes effect in a new process, not an already-running REPL.

Editing and interruption

  • Enter submits complete input; unfinished blocks continue on another line.
  • Ctrl+Enter toggles manual multiline mode. Enter then inserts a newline; Ctrl+Enter again submits the buffer.
  • Shift+Enter inserts a newline.
  • In manual multiline mode, the prompt and continuation marker become yellow on 256-color and true-color terminals; monochrome remains uncolored.
  • First Tab completes an unambiguous name or common prefix. A subsequent Tab can open the completion menu. Menu arrows navigate it; otherwise arrows edit/navigate normally.
  • Ctrl+C interrupts a foreground child or discards input; Shelly remains running.
  • Ctrl+D on an empty buffer exits.

For split pipeline diagrams, use manual multiline mode or paste the complete diagram before submitting it. $SHELLY_TAB_SIZE selects the inherited tab default; a source header #tab-size N and explicit CLI options take precedence.

History storage

$history_path: String | () defaults to ~/.shelly_history.jsonl. $history_limit: Integer defaults to 10,000 entries. Set the path to () for memory-only history. Configure these in the RC so the editor starts with them.

History preserves multiline submissions as entries. Sessions merge records when synchronizing rather than overwriting each other's newest commands. Blank input is not saved. If storage is unavailable or damaged, the REPL reports the problem and falls back to in-memory history rather than repeatedly disrupting the prompt.

Syntax highlighting

$repl_syntax: Boolean enables highlighting. The tokenizer and parser contribute source spans; read-only symbol information distinguishes types, methods, functions, built-ins, aliases, commands, and argument words. For example, let in echo let is an argument, not a declaration keyword.

Each category has a String escape setting $syntax_color_<category>:

Categories Default family
keyword, alias, literal, builtin Logo purples
variable, number Warm gold
type, string Mint/cyan
function, method, field, module Readable blues
command, operator, format Bright cyan
argument, delimiter, comment Light text and subdued grays
escape, error Peach and pink

Settings refresh during the session and respect color capability, including monochrome. Highlighting preserves the original text and tolerates incomplete input. Analysis does not execute user code, import modules, or run commands.


Related: Prompts · Line editing · Editor integration

Clone this wiki locally