Apr 14
Save More History
For the longest time, I’ve put up with grief with the bash history when using multiple terminals. It never seemed to store the history to ~/.bash_history properly. I never invested the time until this morning when I had to find a command in my history for the 100th time only to find that it wasn’t there.
After searching around Google for a while, I eventually stumbled on this gem. Moral of the story: unset HISTSIZE for unlimited history, set histappend to always append the history and not overwrite it, and modify your PROMPT_COMMAND to flush each command to the history file.
Now, in following the spirit of showing the latest in the history, here’s mine:
$ history|awk '{a[$2]++ } END{for(i in a){print a[i] ” ” i}}’|sort -rn|head
82 ls
81 cd
40 eix
30 vi
28 svn
22 ps
21 dmesg
14 killall
12 su
10 gphoto2
Bear in mind, this only had the default 500 lines before today, so the history is only the most recent commands. I’ll do an update some months from now when my history file grows to an enormous size.
tags: bash, history, linux, meme
No Comments
Leave a comment