From 7e7a9e857999b29f52eb2c78d1bd87a0caaaf919 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sun, 4 May 2014 16:59:02 -0700 Subject: [PATCH] fix bug which loses bash history --- .bashrc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.bashrc b/.bashrc index e7c4aaa..067782e 100644 --- a/.bashrc +++ b/.bashrc @@ -83,6 +83,8 @@ if [[ $- == *i* ]]; then if [[ $INSIDE_EMACS ]]; then bind 'set horizontal-scroll-mode on' bind 'set print-completions-horizontally on' + export PAGER=cat + export MANPAGER=cat stty echo else stty werase undef lnext undef stop undef start undef @@ -108,12 +110,14 @@ PS4='$LINENO+ ' HISTFILESIZE= # max commands 1 session can append to history HISTSIZE=100000 +# my history size limit based on lines +HISTFILELINES=1000000 # this needs to be different from the derault because # default HISTFILESIZE is 500 and could clobber our history HISTFILE=$HOME/.bh HISTTIMEFORMAT="%I:%M %p %m/%d " -# duplicate, single letter, and space prepended commands do not go in history -HISTIGNORE="&:?: *" +# consecutive duplicate lines don't go in history +HISTIGNORE="&" export BC_LINE_LENGTH=0 @@ -199,6 +203,10 @@ t() { } +if type ack-grep >/dev/null 2>&1; then + alias ack=ack-grep +fi + gr() { grep -i --binary-files=without-match --color=auto "$@" @@ -712,7 +720,7 @@ hl() { # history limit. Write extra history to archive file. if [[ $1 ]]; then max_lines=$(($1 * 2)) # 2 lines for every history command else - max_lines=1000000 + max_lines=$HISTFILELINES fi linecount=$(wc -l < $HISTFILE) linecount=${linecount:-0} @@ -721,13 +729,10 @@ hl() { # history limit. Write extra history to archive file. tempfile=$(mktemp) [[ $tempfile ]] || { echo mktemp failed; return 1; } head -$prune_lines $HISTFILE >> ${HISTFILE}a \ - && sed -e "1,${prune_lines}d" $HISTFILE > $tempfile \ - && mv $tempfile $HISTFILE + && sed -ie "1,${prune_lines}d" $HISTFILE fi perm_fix $HISTFILE perm_fix ${HISTFILE}_archive - history -c - history -r } # commands to run when bash exits normally -- 2.30.2