Previous: , Up: Interaction [Contents][Index]


6.3 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 is loaded to the history ring from the file eshell-history-file-name at the start of every session, and saved to that file at the end of every session. The default history saving behavior is to overwrite the history file with the whole history ring of the session. If eshell-history-append is non-nil, the history will instead be saved by appending new entries from the session to the history file, which could prevent potential history loss with multiple Eshell sessions. Unlike other shells, such as Bash, Eshell cannot currently be configured to control the size of the history file. In particular, when eshell-history-append is non-nil, the size of the file will keep increasing, and the recommended way to truncate the file is to run the ‘history -w’ command in an Eshell session.

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

History I-search. M-r starts an incremental search in input history. While searching, type C-r to move to the previous match, and C-s to move to the next match in the input history.

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.

If you would like to use the default Isearch key-bindings to search through input history, you may customize eshell-history-isearch to t. That makes, for example, C-r and C-M-r in an Eshell buffer search in input history only. In addition, if the value of eshell-history-isearch is dwim, those commands search in the history when the point is after the last prompt, and search in the buffer when the point is before or within the last prompt.


Previous: Completion, Up: Interaction [Contents][Index]

AltStyle によって変換されたページ (->オリジナル) /