开发者

How to save "history" automatically depending on the directory

开发者 https://www.devze.com 2023-01-17 06:40 出处:网络
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 w

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开发者_JS百科 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


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'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"

0

精彩评论

暂无评论...
验证码 换一张
取 消