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.
1 Answer
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.
-
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? Mar 3, 2011 at 19:38
-
1You could copy your .bash_history file to persistent storage by placing the appropriate commands in .bash.logout.– fpmurphyMar 4, 2011 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. Mar 7, 2011 at 20:56