Initialization File

A Reline application has default key bindings and variable definitions, as determined by the application itself.

You can customize the application’s behavior by specifying key bindings and variable definitions in an initialization file. The initialization file may define:

When a Reline application starts, it reads a user-provided initialization file, whose path is determined thus:

Variables

The initialization file may re-define certain variables.

completion-ignore-case

If set to 'on', Reline performs case-insensitive filename matching and completion.

The default setting is 'off'.

disable-completion

If set to 'on', Reline inhibits word completion. Completion characters (Tab, M-?, and M-*) lose their usual meanings, and are inserted directly into the line.

The default is 'off'.

editing-mode

If set to 'emacs', the default key bindings are similar to Emacs; If set to 'vi', the default key bindings are similar to Vi.

The default is 'emacs'.

emacs-mode-string

Specifies the mode string for Emacs mode; see [Mode Strings][mode strings].

The default is '@'.

enable-bracketed-paste

When set to 'On', Reline is in bracketed-paste mode, which means that it inserts each paste or yank into the editing buffer as a single string of characters, instead of treating each character as if it had been read from the keyboard. This prevents Reline from executing any editing commands bound to key sequences appearing in the pasted text.

The default is 'on'.

history-size

Set the maximum number of entries saved in the history list:

Default value is '-1'

isearch-terminators

Sets the strings of characters that terminate an incremental search without subsequently executing the character as a command.

Default: Esc and C-j.

keymap

Sets the keymap for key binding commands. Values are:

Default is 'emacs'. The value of variable [editing-mode] also affects the default keymap.

keyseq-timeout

Specifies the time (in milliseconds) that Reline will wait for further input when reading an ambiguous key sequence (i.e., one that can form a complete key sequence using the input read so far, or can take additional input to complete a longer key sequence).

If Reline doesn’t receive further input within the timeout, it uses the shorter but complete key sequence.

If this variable is set to a value less than or equal to zero, or to a non-numeric value, Reline waits until another key is pressed to decide which key sequence to complete.

The default '500'.

show-all-if-ambiguous

If set to 'on', input that has more than one possible completion cause the completions to be listed immediately (instead of ringing the bell).

The default is 'off'.

show-mode-in-prompt

If set to 'on', prefixed the mode string to the displayed prompt; see [Mode Strings][mode strings].

The default is 'off'.

vi-cmd-mode-string

Specifies the mode string for Vi command mode; see [Mode Strings][mode strings].

The default is ‘(cmd)’.

vi-ins-mode-string

Specifies the mode string for Vi insertion mode; see [Mode Strings][mode strings].

The default is ‘(ins)’.

Mode Strings

A mode string is a string that is to be displayed immediately before the prompt string when variable [show-mode-in-prompt] is set to 'on'.

There are three mode strings:

The mode string may include [ANSI escape codes][ansi escape codes] which can affect the color (foreground and background) and font (bold, italic, etc.) of the display. The ANSI escape codes must be preceded by escape \1 and followed by escape \2.

Example (turns the mode string green):

"\1\e[32m\2abcd \1\e[0m\2"

Key Bindings

In brief:

"\C-x\M-r":  "Ruby!"          # Key sequence bound to text.
"\C-x\M-c":  ed-clear-screen  # Key sequence bound to function.
Meta-l:      " | less"        # Key name bound to text.
Control-b:   ed-clear-screen  # Key name bound to function.

A key or key sequence may be bound to:

Key Sequences

You can bind a key sequence to text, defining a macro. The key sequence specifies a sequence of one or more keys that are to be mapped to text that is to be inserted when the sequence is typed as input.

This example binds a key sequence to the macro text, which means that in the application pressing C-x followed by M-r inserts the text 'Ruby!':

"\C-x\M-r": "Ruby!"

Note that:

More examples:

# Meta characters and control characters.
"\M-x":     "Alt-x"          # Single meta character.
"\C-a":     "Ctrl-a"         # Single control character.
"\C-x\C-y": "Ctrl-x, Ctrl-y" # Multiple keys.
"\C-xm":    "Ctrl-x, m"      # Control key followed by regular character.

# Escaped regular characters.
"\\":       "Backslash"      # Backslash character.
"\"":       "Double-quote"   # Double-quote character.
"\'":       "Single-quote"   # Single-quote character.

# Special escapes for certain control characters.
"\a":       "Bell"
# (Probably not a good idea to interfere with these.)
# "\b":       "Backspace"
# "\d":       "Delete"
# "\f":       "Form-feed"
# "\n":       "Newline"
# "\r":       "Carriage return"
# "\t":       "Horizontal tab"
# "\v":       "Vertical tab"

# Other forms for the key sequence.
"\001": "Ctrl-a" # Octal number; begins with "\0".
"\x02": "Ctrl-b" # Hexadecimal number; begins with "\x".

You can bind a key sequence to a Reline function, so that the function is called when the key sequence is typed as input. See Functions.

This example binds a key sequence to the function ed-clear-screen, which means that in the application pressing Alt-x clears the screen and reprints the prompt at the top:

"\M-x": ed-clear-screen

This binding is the same as the default binding for C-l. Note that this new binding would override the old one, if any, for that key, but does not disturb other bindings (C-l is still bound to ed-clear-screen).

Key Names

You can bind a single key to text or a function using its key name (instead of the key sequence notation):

Control-b: ed-clear-screen
Meta-L: " | less"

Functions

These are the functions available for binding by a key or key sequence:

Directives

$if, $else, and $endif

The initialization file may contain conditional directives, each of which is an $if/$endif pair, or an $if/$else/$endif triplet.

The $if directive takes a single argument that expresses a condition. If the condition evaluates to true, the expressions in the if-block are evaluated; if it evaluates to false, the expressions in the else-block (if any) are evaluated.

The arguments:

Conditional directives may be nested.

$include

The $include directive takes a single argument, which is the path to a file that is to be read and evaluated as if it were part of the initialization file.

Pro tip: You can use the $include directive to override (in full or in part) another initialization file:

```
$include <filepath>
# Assignments and directives that will override.
# ...