[英]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
命令指定的,而不是环境变量)控制着它的工作方式:
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.