You cannot get the other histories back. All your terminals wrote to your history file, and it sounds like you either had too small of a HISTFILESIZE
value set or you don't have shopt -s histappend
set to append to the HISTFILE
instead of overwriting it. In either case, each terminal wrote to the HISTFILE
in sequence and the list of commands you have left is from the final terminal to do so.
If you want to avoid this in the future, you can set (in your .bashrc
)
shopt -s histappend #append to history file instead of overwriting
HISTFILESIZE=10000 #increase number of stored commands in HISTFILE
This will save all your commands grouped by terminal session when you restart. If you'd rather them be time-ordered, you can use this as well:
#logs every command as it is written to the history file,
#and updates local terminal history to match
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"