我在文件中添加了一行~/.bashrc
,它将所有发出的命令~/.bash_eternal_history
以某种date directory history-number command
格式附加到文件中,例如:
2019-01-08.23:59:32 /home/sport/Desktop 745 pwd
我需要一个reverse-i-search
功能来从自定义历史文件中调出命令来搜索关键字,并使用或键~/.bash_eternal_history
逐个循环浏览每个结果up
down
我怎样才能做到这一点?
答案1
这个,来自man bash
:
HISTFILE
The name of the file in which command history is saved (see HISTORY below). The default value is
~/.bash_history. If unset, the command history is not saved when a shell exits.
HISTFILESIZE
The maximum number of lines contained in the history file. When this variable is assigned a value,
the history file is truncated, if necessary, to contain no more than that number of lines by remov‐
ing the oldest entries. The history file is also truncated to this size after writing it when a
shell exits. If the value is 0, the history file is truncated to zero size. Non-numeric values
and numeric values less than zero inhibit truncation. The shell sets the default value to the
value of HISTSIZE after reading any startup files.