REPL

The interactive Read-Eval-Print Loop starts when mac is run with no arguments.

$ mac
|> print "Hello, Mac!";
Hello, Mac!
|>

Prompt

PromptMeaning
|>Ready for input
..Continuation (inside { }, [ ], or ( ))

Multi-Line Input

Open braces, brackets, or parentheses automatically enter multi-line mode. The REPL waits for all delimiters to close before executing.

|> var greet = (name) -> {
..     return "Hello, " + name;
.. };
|> print greet("Mac");
Hello, Mac

Keyboard Shortcuts

KeyAction
Up / DownNavigate history
Left / RightMove cursor
Option+Left / RightMove by word
Ctrl+AMove to start of line
Ctrl+EMove to end of line
Ctrl+WDelete previous word
Option+DeleteDelete next word
Ctrl+KDelete to end of line
Ctrl+UDelete entire line
Ctrl+LClear screen
Ctrl+CCancel current input
Ctrl+DExit REPL

History

Command history is saved to ~/.mac_history and persists across sessions. Each line of multi-line input is stored individually for easier recall.

Auto-Semicolons

Simple expressions without a trailing ; or } get a semicolon appended automatically.

|> print "no semicolon needed"
no semicolon needed

Pasting

Multi-line code can be pasted directly. Newlines in pasted text are processed through the same brace-tracking as typed input.

Commands

CommandAction
exitExit the REPL
clearClear the screen

Piped Input

When stdin is not a terminal, Mac reads all input as a batch and executes it.

echo 'print "hello";' | mac
# Output: hello