I use my .bash_history all the time using ctrl-R to find complex commands I figured out in the past and since forgot how to run.

I have a large history (50,000) lines, managed by these commands in my .bashrc file. This was certainly copied from someone on the internet in years past:

#for keeping the history from all shells
export HISTIGNORE=lst:df*:top:ssh*:cd*  # don't put these in history
export HISTCONTROL=erasedups    # no duplicate entries
export HISTSIZE=50000           # big big history
shopt -s histappend             # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -r; $PROMPT_COMMAND"

Now, my problem is that with a huge history, I notice my prompt getting a bit laggy. If I nuke my .bash_history things get snappy again. I notice I have a lot of crud in my .bash_history, but manually curating it is not worth the time.

Who has a suggestion to allow me to keep my .bash_history dependance, but to speed up my prompt?


Lose export PROMPT_COMMAND="history -a; history -r; $PROMPT_COMMAND". You don't need to save each command in turn, they are saved automatically at the end of the session.

  • yes but if I have a number of shells going it won't add the up to date history to each unless I close them, no? – lonestar21 Nov 29 '12 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.