Using uLisp from a terminal
As an alternative to using the Serial Monitor in the Arduino IDE you can communicate with uLisp using a serial terminal program. You could also communicate remotely to an Arduino running uLisp using a suitable serial wireless interface.
uLisp includes features to make it more convenient to interact with uLisp from a terminal. There's an integrated line editor, allowing you to delete mistakes during entry, and parenthesis matching to help you keep track of the structure of what you're entering.
The following examples demonstrate this using screen on the Mac, but other terminal programs should behave in a similar way.
You can configure uLisp for use with a terminal by uncommenting defines before you upload uLisp, as explained in the following table:
| Options | Explanation |
| // #define lineeditor // #define vt100 |
What you type is submitted directly to Lisp, so functions will be executed as soon as you type a matching closing patenthesis. |
| #define lineeditor // #define vt100 |
What you type is entered into a uLisp line buffer and only submitted to Lisp when you press Return, so you can edit what you typed with Delete. Also echoes the last line you typed when you press Tab at the start of a line, and provides autocomplete when you press Tab in the middle of a line. |
| #define lineeditor #define vt100 |
Provides the uLisp line buffer as above, and also highlights matching parentheses, for use on terminals that support VT100 codes. |
Using a terminal
On the Mac you can use the Terminal application, in Applications/Utilities, to provide a serial terminal. First you need to find out the name of the USB port the Arduino is connected to.
- At the Terminal prompt type:
ls /dev/tty.*
or:
ls /dev/cu.*
This will display a list of the serial devices:
/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbmodem1411
/dev/tty.Bluetooth-Modem
- Locate the one that corresponds to the USB port; in this case /dev/tty.usbmodem1411.
- Give the command:
screen /dev/tty.usbmodem1411
where the second parameter is whatever you found from the previous command.
The screen serial terminal should run and show the uLisp prompt:

- Enter commands at the uLisp prompt; for example:

By default commands are entered as soon as you type the final closing bracket, and you won't be able to use the delete key to correct mistakes, unless you compile with the Line editor option described below.
Entering programs
Most terminal emulators such as screen allow you to copy and paste text into the terminal, and this provides a convenient way to enter a Lisp function from a web page, such as the uLisp site, or one you have written in a text editor.
Scrolling the window
To make it so you can scroll the Terminal window with the mouse trackpad:
- Uncheck Allow Mouse Reporting on the View menu, or press cmd-R.
Exiting
To exit from screen:
- Type ctrl-A ctrl-\ and answer y to the prompt.
Line editor
To get the line editor, compile uLisp with the option:
#define lineeditor
uLisp provides an input buffer, allowing you to correct mistakes by pressing the delete key, or typing backspace. The line is not submitted to uLisp until you press enter.
The line editor also provides autocomplete and copy last line:
Autocomplete
The autocomplete feature saves you typing by letting you enter a built-in keyword by typing just the first few characters followed by Tab.
The keyword will be completed with one of the uLisp built-in symbols. If there are several keywords starting with what you typed, pressing Tab cycles between them.
If you have loaded a uLisp Extensions File, autocomplete will include any symbols you have defined in your extensions.
Copying the last line
When the cursor is at the start of the line pressing Tab echoes the previous line typed after the uLisp prompt. You can edit it and press Return to submit it again.
Parenthesis matching
If, in addition, you include the option:
#define vt100
uLisp uses ANSI standard terminal codes to implement parenthesis matching, highlighting matching parentheses in inverse video as you type:

Note that the parenthesis matching assumes a screen width of 80 characters.
Customising parenthesis matching
By default parenthesis matching displays matching parentheses in reverse video. You can customise the way that matching parentheses are displayed by editing the #define VT100_HIGHLIGHT at the start of the uLisp source file. The following table gives some suggested values (these are ANSI colour escape sequences):
| Value | Effect |
| "\e[7m" | Reverse video (the default) |
| "\e[42m" | Dark green background |
| "\e[41m" | Dark red background |
| "\e[102m" | Bright green background* |
* doesn't work on all VT100 emulations.
Pasting in long programs on the ESP32
On most uLisp platforms a convenient way of entering a long program is to copy it from a listing, paste it into the Arduino IDE Serial Monitor input field, or at a terminal prompt, and press Return to enter it.
For example, you could display this Infinite precision arithmetic program:
Do Select All, Copy, then in the Serial Monitor input field do Paste.
You could use the same technique to enter a Lisp program you are writing in a text editor.
This works on most platforms, apart from ESP32 boards that use the built-in CDC USB interface, due to a limitation of the rate at which they can process the serial input. On those boards, pasting a long listing causes the serial interface to lock up, requiring a reset of the board.
The best solution is to use one of the following terminal programs that offer a delay on Paste:
- CoolTerm, available for both Mac, Windows, and Linux. This adds a delay to the standard Paste menu option.
- iTerm2, available for Mac. This offers an Edit->Paste Special->Paste Slowly menu option. It also provides VT100 emulation.
Using CoolTerm
CoolTerm is available for free download for the Mac, Windows, or Linux from Roger Meier's site:
The Paste command in CoolTerm seems to work without problems on ESP32 boards using the CDC USB interface.
To set it up:
- Click the Options button in the toolbar.
- Click the Serial Port tab, and select the board's serial port from the Port menu:

- Click the Connect icon in the toolbar, and you should get the uLisp prompt.
- Copy the listing you want to enter, making sure to include the comment at the top of the listing, and do Paste into the terminal window.
The comment disables echo while the listing is being transferred, which prevents
You should see the names of the functions being entered into uLisp:

When you're interacting with uLisp, rather than pasting in a listing, you might find it more convenient to use Line Mode:
- In Options click the Terminal tab and set the Terminal Mode to Line Mode:

In line mode you can edit the line, in a separate field at the bottom of the terminal window, before pressing Return to enter it.
Using iTerm2
Another alternative for Mac platforms is iTerm2:
This provides access to screen with VT100 emulation, and provides an Edit->Paste Special->Paste Slowly option for pasting in long programs on ESP32 platforms that use the hardware CDC USB.
