Don't save current bash session to history

2020-05-12 10:55发布

I notice that when opening .bash_history that it contains only the entries from my previous session, it seems that the current session is appended only on exit. Is there any way to prevent the current session from saving? Even crashing bash is an option if one knows how to do that. I found that I can kill -9 the process, but if there is a better way I would love to know.

标签: bash
7条回答
Animai°情兽
2楼-- · 2020-05-12 11:55

I know this is an old thread. Just wanted to add this for completion:

If you just want specific commands not to be saved check if HISTCONTROL variable is set: HISTCONTROL=ignoreboth or HISTCONTROL=ignorespace

Every command that starts with a leading space will not be put in the history.

Just my 2 cents.

查看更多
登录 后发表回答