3 ms·
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 f
by ajphdiv 7y ago
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.
- masukomi 7y agonot sure if this is your problem but i think most shells (like bash) don't add the history in their buffer to the common history until you close the session. thus recent history in one window is different than another. That _may_ be what you're dealing with. I believe there are ways to tweak it to always write everything to the common history immediately.
- jdevera 7y agoI also use those. They came from here: https://eli.thegreenplace.net/2013/06/11/keeping-persistent-history-in-bash/ https://eli.thegreenplace.net/2013/06/11/keeping-persistent-...