.bash_history does not update in Git for Windows (git bash)

匿名 (未验证) 提交于 2019-12-03 01:47:02

问题:

I am using Git for Windows (ver. 1.7.8-preview20111206) and even though I have a .bash_history file in my HOME folder, it never automatically gets updated. When I start Git Bash, I can see in the history commands that I manually added to the .bash_history file, but it does not get updated automatically.

I used the shopt -s histappend command to make sure that the history gets saved every time I close the shell, but it does not work.

If I manually use the history -w command, then my file gets updated, but I would want to understand why the shopt command does not work as I understand it should.

Anyone can tell me why is this behavior happening?

Thanks in advance

回答1:

I put this in my ~/.bash_profile

PROMPT_COMMAND='history -a' 


回答2:

As it was said here, to save git bash history on Windows you must not close the terminal with X button. Use exit command instead. History of commands will be saved then regardless of configuration mentioned in the accepted answer.



回答3:

If you use git bash for windows 8, just put this in your ~/.bash_logout file:

history > .bash_history 

Obviously you need a ~/.bash_history file.

Regards.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!