Can you share how you do this please?
Here are pointers: This install fzf into your bash, and apply small patch on fzf scripts to use bash history: https://github.com/mic47/linux-configuration/blob/master/scr... Some more fzf stuff to put into your bashrc: https://github.com/mic47/linux-configuration/blob/master/bas... This is .super_history setup: https://github.com/mic47/linux-configuration/blob/master/bas... https://github.com/mic47/linux-configuration/blob/master/bas...
This reminds me that I should probably modularize my setup.
However, in my `.bashrc`, I have:
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
}
# Stuff to do on PROMPT_COMMAND
run_on_prompt_command()
{
log_bash_persistent_history
}
PROMPT_COMMAND="run_on_prompt_command"
HISTTIMEFORMAT="%d/%m/%y %T "
alias phgrep='cat ~/.persistent_history|grep --color'
alias hgrep='history|grep --color'
This doesn't save all of the information like the current shell, working directory, etc... but you could easily modify it to include that information. It also doesn't do all of the context-aware piping, you have to rely on grep. But just having a really good persistent history is itself insanely useful.My setup was itself stolen from someone else on HN a few years ago, and I've since forgotten their name.