文档介绍:Bash History Cheat Sheet
Emacs and Vi history editing keyboard shortcuts:
Shortcut Description
Emacs Mode Shortcuts:
CTRL-p Fetch the mand from the history list.
CTRL-n Fetch the mand from the history list.
CTRL-r Search history backward (incremental search).
CTRL-s Search history forward (incremental search).
Meta-p Search backward using non-incremental search.
Meta-n Search forward using non-incremental search.
Meta-< Move to the first line in the history.
Meta-> Move to the end of the history list.
Vi Mode Shortcuts:
k Fetch the mand from the history list.
j Fetch the mand from the history list.
/string or CTRL-r Search history backward for mand matching string.
?string or CTRL-s Search history forward for mand matching string.
n Repeat search in the same direction as previous.
N Repeat search in the opposite direction as previous.
G Move to the N-th history line (for example, 15G).
History behavior modification via shell variables:
Shell Variable Description
HISTFILE Controls where the history file gets saved. Set to /dev/null not to keep history.
Default: ∼/.bash history.
HISTFILESIZE Controls how many mands to keep in HISTFILE.
Default: 500.
HISTSIZE Controls how many mands to keep in the history list of current session.
Default: 500.
HISTIGNORE Controls mands to ignore and not save to the history list. The variable takes