如何保存“历史”根据目录自动
我广泛使用 shell 进行工作。一周后,当我继续从事某个项目时,我转到某个“文件夹”,然后意识到我不记得自己在做什么。有时,在停止工作之前,我会做的是:
history > DIRX_HISTORY_20100922
稍后我看看我使用的命令,我可以更好地记住我在做什么。
我想知道是否某种脚本或其他东西可以在每次我在目录中键入命令时自动执行此操作,因此会创建此 DIRX_HISTORY_20100922 并根据日期和目录名称修改一个新的。
谢谢
I work extensively using the shell. When I continue working on some project one week later, I go to some "folder" and realize that I do not remember what I was doing. Sometimes and before stopping work what I do is:
history > DIRX_HISTORY_20100922
so later I have a look at the commands I used, I can remember much better what I was doing.
I wonder if somehow, some script or something could do this automatically each time I type a command in a directory, so this DIRX_HISTORY_20100922 is created and a new one is modified depending on the date and on the directory name.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看我的历史记录功能。它们保存当前目录以及执行的命令。您可以
grep
查找该目录,它会显示您在那里使用的命令。Have a look at my history logging functions. They save the current directory along with the command that was executed. You can
grep
for the directory and it will show you the commands that you were using there.Bash 的 PROMPT_COMMAND 变量可用于将您输入的每个命令的历史记录的最后一行保存到文件中。
IE。
PROMPT_COMMAND="历史记录 1 >> DIRX_HISTORY"
Bash's PROMPT_COMMAND variable can be used to save the last line of your history to a file for every command you enter.
ie.
PROMPT_COMMAND="history 1 >> DIRX_HISTORY"