I’ve trying to move some console work to my mobile device, iPhone, especially.
So I start to use Blink Shell, which is an iOS app supports ssh and mosh connection.
Then, naturally I bump in to the problem when there is more than one bash session undergoing, the bash command history gets mess up.
If you ever use !
numbers, eg. !1, run the first command in bash history, this situation gets annoying at some point.
To manipulate bash history, we need these settings:
# Append command history to .bash_history
And here is what I want:
- every new bash session loads all previous history
- existing session save commands after each enter hits
This is what I put into
~/.bashrc (in Ubuntu Linux, you may also put into .bash_profile, but eventually .bashrc will gets loaded)
export PROMPT_COMMAND="history -a; history -r; $PROMPT_COMMAND"
Also, I found this idea  to archive your history once in a while.
Simply added following into my bashrc:
On a final thought, it would be interesting if I can keep all the commands I typed and analyzing later in my life.