Erlang -- tty - A Command-Line Interface

Erlang Run-Time System Application (ERTS)

User's Guide

Version 10.6

- User's Guide
- Reference Manual
- Internal Documentation
- Release Notes
- PDF
- Top

- Expand All
- Contract All

### Chapters

- Introduction
  - Top of chapter
  - Scope
  - Prerequisites
- Communication in Erlang
  - Top of chapter
  - Passing of Signals
  - Synchronous Communication
  - Implementation
- Time and Time Correction in Erlang
  - Top of chapter
  - New Extended Time Functionality
  - Terminology
  - Introduction
  - Time Correction
  - Time Warp Safe Code
  - Time Warp Modes
  - New Time API
  - Support of Both New and Old OTP Releases
- Match Specifications in Erlang
  - Top of chapter
  - Grammar
  - Function Descriptions
  - Match target
  - Variables and Literals
  - Execution of the Match
  - Differences between Match Specifications in ETS and Tracing
  - Tracing Examples
  - ETS Examples
- How to Interpret the Erlang Crash Dumps
  - Top of chapter
  - General Information
  - Scheduler Information
  - Memory Information
  - Internal Table Information
  - Allocated Areas
  - Allocator
  - Process Information
  - Port Information
  - ETS Tables
  - Timers
  - Distribution Information
  - Loaded Module Information
  - Fun Information
  - Process Data
  - Atoms
  - Disclaimer
- How to Implement an Alternative Carrier for the Erlang Distribution
  - Top of chapter
  - Introduction
  - Distribution Module
  - The Driver
  - Putting It All Together
- How to Implement an Alternative Service Discovery for Erlang Distribution
  - Top of chapter
  - Introduction
  - Discovery module
- The Abstract Format
  - Top of chapter
  - Module Declarations and Forms
  - Atomic Literals
  - Patterns
  - Expressions
  - Clauses
  - Guards
  - Types
  - The Abstract Format after Preprocessing
- tty - A Command-Line Interface
  - Top of chapter
  - Normal Mode
  - Shell Break Mode
- How to Implement a Driver
  - Top of chapter
  - Introduction
  - Sample Driver
  - Compiling and Linking the Sample Driver
  - Calling a Driver as a Port in Erlang
  - Sample Asynchronous Driver
  - An Asynchronous Driver Using driver_async
- Inet Configuration
  - Top of chapter
  - Introduction
  - Configuration Data
  - User Configuration Example
- Socket Usage
  - Top of chapter
  - Introduction
  - Socket Options
- External Term Format
  - Top of chapter
  - Introduction
  - Distribution Header
  - ATOM_CACHE_REF
  - SMALL_INTEGER_EXT
  - INTEGER_EXT
  - FLOAT_EXT
  - PORT_EXT
  - NEW_PORT_EXT
  - PID_EXT
  - NEW_PID_EXT
  - SMALL_TUPLE_EXT
  - LARGE_TUPLE_EXT
  - MAP_EXT
  - NIL_EXT
  - STRING_EXT
  - LIST_EXT
  - BINARY_EXT
  - SMALL_BIG_EXT
  - LARGE_BIG_EXT
  - REFERENCE_EXT (deprecated)
  - NEW_REFERENCE_EXT
  - NEWER_REFERENCE_EXT
  - FUN_EXT
  - NEW_FUN_EXT
  - EXPORT_EXT
  - BIT_BINARY_EXT
  - NEW_FLOAT_EXT
  - ATOM_UTF8_EXT
  - SMALL_ATOM_UTF8_EXT
  - ATOM_EXT (deprecated)
  - SMALL_ATOM_EXT (deprecated)
- Distribution Protocol
  - Top of chapter
  - EPMD Protocol
  - Distribution Handshake
  - Protocol between Connected Nodes
  - New Ctrlmessages for distrvsn = 1 (Erlang/OTP R4)
  - New Ctrlmessages for distrvsn = 2
  - New Ctrlmessages for distrvsn = 3 (Erlang/OTP R5C)
  - New Ctrlmessages for distrvsn = 4 (Erlang/OTP R6)
  - New Ctrlmessages for Erlang/OTP 21
  - New Ctrlmessages for Erlang/OTP 22

# 9 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 one of two modes:

- Normal mode, in which text lines can be edited and sent to the shell.

- Shell break mode, which allows the user to kill the current shell, start multiple shells, and so on.

### 9.1 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.
- M-f means pressing the Esc key and the letter f in sequence.
- Home and End represent the keys with the same name on the keyboard.
- Left and Right represent the corresponding arrow keys.

Key Sequence | Function
Home | Beginning of line
C-a | Beginning of line
C-b | Backward character
C-Left | Backward word
M-b | Backward word
C-d | Delete character
M-d | Delete word
End | End of line
C-e | End of line
C-f | Forward character
C-Right | Forward word
M-f | Forward word
C-g | Enter shell break mode
C-k | Kill line
C-u | Backward kill line
C-l | Redraw line
C-n | Fetch next line from the history buffer
C-p | Fetch previous line from the history buffer
C-t | Transpose characters
C-w | Backward kill word
C-y | Insert previously killed text
C-] | Insert matching closing bracket

Table 9.1: tty Text Editing

### 9.2 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