Managing shell history

On linux, if you use multiple terminals, and are a fan of the history command because you always forget which one actually worked, then you have probably noticed something weird : some of your commands sometimes disappear because they don’t appear in history.

It is due to the fact that, by default, the history is saved when a terminal is closed. But more than saved I should say replaced ! Meaning that the history is actually the one of the current terminal plus the one of the last terminal you closed.

If you want to have your history saved across multiple terminal, then I found this link here to guide you. Basically, you need to add

shopt -s histappend

to your .basrc file.

Only thing I’d like to do now, is to have the history file being saved every time I enter a command, not only when the terminal is closed, so that I could easily share information across multiple terminals … But I have not yet found the answer ! If you have it, talk to me !

Leave a Reply