2.7 History

The ‘history’ command shows all commands kept in the history ring as numbered list. If the history ring contains eshell-history-size commands, those numbers change after every command invocation, therefore the ‘history’ command shall be applied before using the expansion mechanism with history numbers.

The n-th entry of the history ring can be applied with the ‘!n’ command. If n is negative, the entry is counted from the end of the history ring.

When history event designators are enabled (by adding eshell-expand-history-references to eshell-expand-input-functions), ‘!foo’ expands to the last command beginning with foo, and ‘!?foo’ to the last command containing foo. The n-th argument of the last command beginning with foo is accessible by !foo:n.

The history ring is loaded from a file at the start of every session, and written back to the file at the end of every session. The file path is specified in eshell-history-file-name. Unlike other shells, such as Bash, Eshell can not be configured to keep a history ring of a different size than that of the history file.

Since the default buffer navigation and searching key-bindings are still present in the Eshell buffer, the commands for history navigation and searching are bound to different keys:

M-r
M-s

History I-search.

M-p
M-n

Previous and next history line. If there is anything on the input line when you run these commands, they will instead jump to the previous or next line that begins with that string.