Fun hacks, WP plugins, photography, and PKI junk. Languishing since 2008.
Improved Bash History
If you use multiple shells simultaneously (in my case with Terminal.app on OS X) you’ve undoubtedly noticed that the history of the last closed shell clobbers any commands you might have executed in others. This makes it difficult to use reverse-i-search to find commands you recall using. However, with a few modifications to your bash history you can greatly increase its utility.
export HISTCONTROL=erasedups export HISTSIZE=10000 export HISTTIMEFORMAT="%D %T " export HISTIGNORE="&:ls:exit" shopt -s histappend
Save the above lines to your home directory’s .profile (or .bash_profile) and your shell history will now prevent duplicates, have a maximum of 10,000 items, append a timestamp to all new commands, exclude a list of commands, and append history between shells.
| Print article | This entry was posted by Paul Kehrer on October 30, 2009 at 2:45 pm, and is filed under Posts. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 4 months ago
Best tip ever! Thank you!
about 3 months ago
effing excellent!
about 1 month ago
It’s been a long time coming! i’ve finally included these awesome tips in my .profile. Here is another suggestion for HISTIGNORE. history. I hate seeing “history” in my history. Good stuff!