I always find my history not complete when using tmux. I started using these functions in my profile to collect everything. I don't remember the source of the functions.
log_bash_persistent_history()
{
[[
$(history 1) =~ ^\ *[0-9]+\ +([^\ ]+\ [^\ ]+)\ +(.*)$
]]
local date_part="${BASH_REMATCH[1]}"
local command_part="${BASH_REMATCH[2]}"
if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ]
then
echo $date_part "|" "$command_part" >> ~/.persistent_history
export PERSISTENT_HISTORY_LAST="$command_part"
fi
}
run_on_prompt_command()
{
log_bash_persistent_history
}
alias phgrep='cat ~/.persistent_history|grep --color'
I like the idea of a hub, as I do a lot of work inside docker containers and vms -- so this could be tailored to help me collect all my history.