简体   繁体   English

TCSH命令记录器

[英]TCSH command logger

Is there a way to log history(and save it in .history file) in tcsh every time a command is entered in the shell ? 每次在外壳中输入命令时,是否有一种方法可以在tcsh中记录历史记录(并将其保存在.history文件中)? Something like the solution given here for bash: Bash Command Logger 类似于此处为bash提供的解决方案: Bash命令记录器

Yes. 是。 There are several shell variables (those specified by the set command, and not environment variables) that control how this works: 有几个Shell变量(由set命令指定的,而不是环境变量)控制着它的工作方式:

  • history specifies how many commands will be remembered in the current shell 历史记录指定当前外壳中将记住多少个命令
  • histfile names the file to save the history to (which is ~/.history by default) histfile命名将历史记录保存到的文件(默认为〜/ .history
  • savehist which specifies that the history of commands will be recorded to the history file savehist ,它指定将命令的历史记录到历史文件中

For example, you might put the following in your .tcshrc file: 例如,您可以将以下内容放入.tcshrc文件中:

set history = 1000  # remember 1000 commands
set savehist = 100  # write the last 100 commands to $histfile
set histfile = "~/.my-history"

Also, according to the manual page, doing a history -S will write the current history (as controlled by the above variables). 另外,根据手册页,执行history -S将写入当前历史记录(由上述变量控制)。

NB: the history -S didn't seem to work well on Mac OSX's 10.8 for me; 注意: history -S在我看来不适用于Mac OSX 10.8; it hung the shell 它挂了壳

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM