如何从存储在 TCSH 历史记录中排除某些命令?

TCS*_*rad 4 tcsh command-history

我将命令行历史记录存储在 TCSH 中,但我想防止某些频繁的、简单的命令(例如“exit”、“cd”)包含在历史记录中(历史记录仅包含固定数量的命令,因此我只想保留有用的命令)。

有没有办法指定一个“排除列表”——一个包含不会添加到当前历史文件中的命令的列表?这样,我可以只保留历史记录中最相关的命令,并过滤掉我不想阻塞历史记录的命令。

小智 5

这不完全是您想要的,但这可能会有所帮助:

  histdup (+)
    Controls handling of duplicate entries in the history list.  If set to `all' only unique his-
    tory  events are entered in the history list.  If set to `prev' and the last history event is
    the same as the current command, then the current command is not entered in the history.   If
    set  to  `erase'  and the same event is found in the history list, that old event gets erased
    and the current one gets inserted.  Note that the `prev' and `all' options  renumber  history
    events so there are no gaps.
Run Code Online (Sandbox Code Playgroud)

因此,您在 .tcshrc 中放置了一个“set histdup = all”,虽然您仍然会在历史记录中获得一些简单的命令,但您只会获得每个命令的一个实例,这至少可以减少混乱。