Change history size and add persistent history tool

This commit is contained in:
Alexander Hosking 2017-03-07 08:14:23 -05:00
parent 077002598a
commit cdf9f5413a

View File

@ -54,8 +54,11 @@ HISTCONTROL=ignoreboth
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
HISTSIZE=-1
HISTFILESIZE=-1
# History Timestamps
HISTTIMEFORMAT="%d/%m/%y %T "
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
@ -150,3 +153,20 @@ if [ -f `which powerline-daemon` ]; then
POWERLINE_BASH_SELECT=1
. /usr/share/powerline/bindings/bash/powerline.sh
fi
# Persistent Bash History to alternative dotfile
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
}
log_bash_persistent_history