From cdf9f5413a796f339d39f01b66696a8b9643593b Mon Sep 17 00:00:00 2001 From: Alexander Hosking Date: Tue, 7 Mar 2017 08:14:23 -0500 Subject: [PATCH] Change history size and add persistent history tool --- run/.bashrc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/run/.bashrc b/run/.bashrc index 6b735c9..155b581 100644 --- a/run/.bashrc +++ b/run/.bashrc @@ -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