I want to speed up access to my .bash_history file. I have my PROMPT_COMMAND set to do history -a; history -r, so there is a significant delay in getting a new prompt. I want to see if I can speed this up by memory mapping .bash_history to a linux device (say /dev/history) and then using that device as my HISTFILE.

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

A pretty standard solution for creating memory-mapped filesystems under Linux is tmpfs. For your use case you could put your .bash_history file there. Don't forget to set HIST_FILE to the new location in your ~/.bashrc.

Alternatively, you could try to improve caching of the filesystem where your home directory lives.

link|improve this answer
It's my understanding that tempfs is transient, i.e. my .bash_history would go away if I reboot. I'd like my .bash_history to be persistant. Or is there a way to make files in tempfs sync with files in another filesystem? – John Didion Mar 3 '11 at 19:38
You could copy your .bash_history file to persistent storage by placing the appropriate commands in .bash.logout. – fpmurphy Mar 4 '11 at 17:42
That sounds like an acceptable solution. I'm still screwed if my computer crashes (since .bash_history never gets written to disk). I'd really like to find a method that periodically stores the copy in tempfs to disk. – John Didion Mar 7 '11 at 20:56
feedback

Your Answer

 
or
required, but never shown

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