View Source tty - A Command-Line Interface

tty is a simple command-line interface program where keystrokes are collected and interpreted. Completed lines are sent to the shell for interpretation. A simple history mechanism saves previous lines, which can be edited before sending them to the shell. tty is started when Erlang is started with the following command:

erl

tty operates in several different modes:

  • Normal mode, in which text lines can be edited and sent to the shell.
  • Search mode, in which the user can search for previous commands in the history buffer.
  • Shell break mode, which allows the user to kill the current shell, start multiple shells, and so on.

Normal Mode

In normal mode keystrokes from the user are collected and interpreted by tty. Most of the Emacs line-editing commands are supported. The following is a complete list of the supported line-editing commands.

Typographic conventions:

  • C-a means pressing the Ctrl key and the letter a simultaneously.
  • C-S-a means pressing the Ctrl key, the Shift key, and the letter a simultaneously.
  • M-f means pressing the Esc key and the letter f in sequence or pressing the Alt key and the letter f simultaneously.
  • Home and End represent the keys with the same name on the keyboard.
  • Left, Right, Up and Down represent the corresponding arrow keys.
  • When a function has multiple possible key sequences they are listed on individual lines in the Key Sequence column.
Key SequenceFunction
HomeBeginning of line
C-aBeginning of line
C-bBackward character
C-Left or M-LeftBackward word
M-bBackward word
C-dDelete character
M-dDelete word
EndEnd of line
C-eEnd of line
C-fForward character
C-Right or M-RightForward word
M-fForward word
C-gEnter shell break mode
C-kKill line
C-uBackward kill line
C-lClears the screen
M-cClears the current expression
M-lRedraw line
C-nFetch next line from the history buffer
C-o or M-oEdit the current line using the editor specified in the environment variable VISUAL or EDITOR. The environment variables can contain arguments to the editor if needed, for example VISUAL="emacs -nw". On Windows the editor cannot be a console based editor.
C-pFetch previous line from the history buffer
M-rFormat current expression using shell:format_shell_func/1
C-rEnter search mode and then search backward in the shell history
C-sIn search mode, search forward in the shell history
C-tTranspose characters
C-wBackward kill word
C-yInsert previously killed text
C-]Insert matching closing bracket
C-Up or M-UpNavigate one row up when editing multiple lines
C-Down or M-DownNavigate one row down when editing multiple lines
M-EnterInsert a new line at cursor
M-< or M-S-UpNavigate to the start of the current expression
M-> or M-S-DownNavigate to the end of the current expression
Tab or C-iAutocomplete current expression, or show completion suggestions
M-cClear current expression
M-hDisplay help for the module or function closest on the left of the cursor.
PageUpScroll the expand, search or help buffer 5 lines upwards.
PageDownScroll the expand, search or help buffer 5 lines downwards.

Table: tty Text Editing

Shell Break Mode

In this mode the following can be done:

  • Kill or suspend the current shell
  • Connect to a suspended shell
  • Start a new shell