ela
Contents

ManualShell

Line editing and history

In the terminalela --spec line-editing-and-history

  • The keys are Emacs-style: arrows, Ctrl-A / Ctrl-E (line start / end), Ctrl-W (delete word), Ctrl-R (history search), Up and Down (history).
  • The shell runs the terminal in raw mode while a line is typed; keys arrive as escape sequences and redraws are written as escape sequences. A running command has the terminal as usual.
  • The history file is $XDG_STATE_HOME/ela/history, its folder made when missing. It holds one entry a line, oldest first; a backslash is written \\ and a newline \n, so a block typed over several lines is one entry, and Up brings it back whole.
  • History is shared between open shells. Each finished statement is appended to the file under a lock, so no shell loses another's lines, and before each prompt the shell takes in what the others appended. The file is rewritten with its newest entries once it grows a quarter past the history's size.
  • A line already in the history moves to its end: each line is kept once. A line of one character or less is not kept. A line with an error is kept, so it can be brought back and mended.

History size: 10,000 entries by default, set in init.ela with history_size(n), from 1 to 100,000. Anything else is an error that says the range:

history_size(20000)

history_size works only in the interactive shell; in a script it is an error. Typed at the prompt, it takes effect at the next prompt.