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:
1 | # 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)
1 | export PROMPT_COMMAND="history -a; history -r; $PROMPT_COMMAND" |
Archiving bash_history
Also, I found this idea [0] to archive your history once in a while.
Simply added following into my bashrc:
1 | Keep=768 |
On a final thought, it would be interesting if I can keep all the commands I typed and analyzing later in my life.