REPL (Interactive Shell)
Harneet includes an interactive Read–Eval–Print Loop (REPL) for quickly testing code, exploring APIs, and iterating on ideas.
Start the REPL
You should see the prompt:
Multiline Editing
The REPL supports multiline input: - Balanced delimiters keep the continued prompt until closed: (), [], {}. - Quoted strings keep the continued prompt until closed. - A trailing backslash \ continues to the next line. - Entering a blank line submits the current block.
Continued prompt:
Example:
Interactive History
- Use Up/Down arrow keys to navigate history.
- Press Ctrl-R to search history (prompts for a term and recalls the latest match).
- History is persisted to
~/.harneet_historywith newlines escaped.
View or search from within the REPL: - :history – Show all history entries - :search <term> – Filter history by substring (case-insensitive)
Editor Integration
Open your editor to write a block and run it on exit:
:edit– Opens$EDITOR. Fallbacks:vim,nano,vi,ed.
Variable Inspection
Inspect currently visible variables across scopes:
:vars
Example output:
File Operations
:load <file>– Run the contents of a file in the current REPL environment:save <file>– Save the last submitted block to a file
Environment Management
:reset– Reset the REPL environment (clears variables):quit,:q,exit– Exit the REPL
Command Summary
:help– Show help:edit– Open editor and run on exit:history– Show persisted history:search <term>– Filter history:vars– List current variables:load <file>– Run a file into the current environment:save <file>– Save last submitted block:reset– Reset environment:quit|:q|exit– Exit
Tips
- Multiline blocks are submitted on a blank line.
- History stores each submitted block as a single entry (with newlines escaped).
- For complex edits, use
:editto take advantage of your editor features.