{"id":135,"date":"2010-11-22T20:17:30","date_gmt":"2010-11-23T03:17:30","guid":{"rendered":"https:\/\/vernon.mauery.com\/content\/?p=135"},"modified":"2010-11-22T20:17:30","modified_gmt":"2010-11-23T03:17:30","slug":"tame-your-bash-history","status":"publish","type":"post","link":"https:\/\/vernon.mauery.com\/content\/2010\/11\/22\/tame-your-bash-history\/","title":{"rendered":"Tame your bash history"},"content":{"rendered":"<p>I am a packrat, but I do like a bit of order.  This makes maintaining my bash history difficult.  There are some commands that I use frequently that seem to fill up my history file making it hard to keep some of the lesser used, yet very important commands in the history.  Finally sick of the problem, I poured over the manpage for bash and found the section on HISTCONTROL.  From the description there, I found that this along with HISTIGNORE, I can almost eliminate my problem of my bash history getting too full of stupid common commands.<\/p>\n<p>I added this to my ~\/.bash_profile:<\/p>\n<p><code><br \/>\nexport HISTIGNORE=\"&amp;:ls:[bf]g:disown:cd:cd[ ]-:exit:^[ t]*\"<br \/>\nexport HISTCONTROL=ignoredups:ignorespace:erasedups<br \/>\nexport HISTFILESIZE=2000<br \/>\n<\/code><\/p>\n<p>Here is the snippet from the bash manual that corresponds to these controls:<\/p>\n<pre>\n       HISTCONTROL<br \/>\n              A colon-separated list of values controlling how commands are saved on the  history<br \/>\n              list.   If  the list of values includes ignorespace, lines which begin with a space<br \/>\n              character are not saved in the history list.  A value of  ignoredups  causes  lines<br \/>\n              matching  the  previous  history  entry  to not be saved.  A value of ignoreboth is<br \/>\n              shorthand for ignorespace and ignoredups.  A value of erasedups causes all previous<br \/>\n              lines  matching  the  current  line to be removed from the history list before that<br \/>\n              line is saved.  Any value not in the above list  is  ignored.   If  HISTCONTROL  is<br \/>\n              unset,  or  does  not include a valid value, all lines read by the shell parser are<br \/>\n              saved on the history list, subject to the value of HISTIGNORE.  The second and sub-<br \/>\n              sequent lines of a multi-line compound command are not tested, and are added to the<br \/>\n              history regardless of the value of HISTCONTROL.<br \/>\n       HISTFILESIZE<br \/>\n              The maximum number of lines contained in the history file.  When this  variable  is<br \/>\n              assigned a value, the history file is truncated, if necessary, by removing the old-<br \/>\n              est entries, to contain no more than that number of lines.  The  default  value  is<br \/>\n              500.   The  history  file  is  also truncated to this size after writing it when an<br \/>\n              interactive shell exits.<br \/>\n       HISTIGNORE<br \/>\n              A colon-separated list of patterns used to decide which  command  lines  should  be<br \/>\n              saved  on  the history list.  Each pattern is anchored at the beginning of the line<br \/>\n              and must match the complete line (no implicit `*' is appended).   Each  pattern  is<br \/>\n              tested  against the line after the checks specified by HISTCONTROL are applied.  In<br \/>\n              addition to the normal shell pattern matching characters, `&amp;' matches the  previous<br \/>\n              history  line.   `&amp;'  may  be  escaped  using a backslash; the backslash is removed<br \/>\n              before attempting a match.  The second and subsequent lines of  a  multi-line  com-<br \/>\n              pound  command are not tested, and are added to the history regardless of the value<br \/>\n              of HISTIGNORE.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am a packrat, but I do like a bit of order. This makes maintaining my bash history difficult. There are some commands that I use frequently that seem to fill up my history file making it hard to keep some of the lesser used, yet very important commands in the history. Finally sick of &hellip; <a href=\"https:\/\/vernon.mauery.com\/content\/2010\/11\/22\/tame-your-bash-history\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Tame your bash history<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[11,42],"class_list":["post-135","post","type-post","status-publish","format-standard","hentry","category-hobbies","tag-software","tag-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/posts\/135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/comments?post=135"}],"version-history":[{"count":0,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/posts\/135\/revisions"}],"wp:attachment":[{"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/media?parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/categories?post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vernon.mauery.com\/content\/wp-json\/wp\/v2\/tags?post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}