Member-only story
How to organize automatically your bash history ??
The bash history is a powerful tool. Remember when you begin a new job a reset your desktop and you need to start a new history. No ctrl+r and you lost your effiency.
In this post, I suggest you a tricks as an idea. I mean that it’s to give you something that you can adopt but also change for your use cases.
You can reformat and archive your bash history
In the most of time, the .bash_history makes a great job but you can improve it.
To do that you can edit the .bash_profile file in your home.
For example, you can change the format of the history to store in each line : the datetime, the location where the command was run and the entire command line.
And maybe you want to keep your history organize per month and keep only 10 months.
Ok let’s go !!!
Some commands
First, create the core line with the history
echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.logs/bash-history-$(date "+%y-%m").log