<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0">
    <title>Comments for Daily history files for Bash</title>
    <link rel="alternate" type="text/html" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash" />
    <link rel="self" type="application/atom+xml" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash" />
    <id>tag:bradchoate.com,2008://4-</id>
    <updated>2006-05-19T22:00:31Z</updated>
    <subtitle>The man, the legend.</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.2-en</generator>
 

<entry>
    <id>tag:bradchoate.com,2006://4.2522-comment:5016</id>
    <thr:in-reply-to ref="tag:bradchoate.com,2006://4.2522" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash"/>
 
    <link rel="alternate" type="text/html" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash#c5016" />
    <title>Comment from Yann on 2006-05-21</title>
    <author>
        <name>Yann</name>
        <uri>http://yann.typepad.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://yann.typepad.com">
        <![CDATA[<p>what about keeping a smaller HISTSIZE, and using a cron instead to populate .history with backups from .bash_history ?</p>

<p>This way you shouldn't have duplicates in your backup while keeping the usual continuous .history file for your day-to-day history scrubbing.</p>]]>
    </content>
    <published>2006-05-21T08:39:06Z</published>
</entry>

<entry>
    <id>tag:bradchoate.com,2006://4.2522-comment:8604</id>
    <thr:in-reply-to ref="tag:bradchoate.com,2006://4.2522" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash"/>
 
    <link rel="alternate" type="text/html" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash#c8604" />
    <title>Comment from reeses on 2006-08-27</title>
    <author>
        <name>reeses</name>
        <uri>http://www.astrogoth.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.astrogoth.com">
        <![CDATA[<p>I needed to be a snoop and log everything a particular user was doing and keep multiple login shell sessions separate.  As a result, I added the time of day to $HISTFILE.</p>

<p>Then I wondered why it didn't work.  I logged in, I su -'d, and the file never appeared.  I could touch the file and create it in ~ from the command line.</p>

<p>Finally, I added the touch ~/blah to the .profile, and received an error message.  Changing ~ to the full path was sufficient to solve the problem.</p>

<p>This obviously isn't a general problem (~ is not a traditional home, but more like having ~apache be /var/apache), but because bash appears to fail silently if $HISTFILE is not "valid" for whatever reason, a quick "touch $HISTFILE" added to the .profile should give more helpful diagnostic output.</p>]]>
    </content>
    <published>2006-08-28T00:10:51Z</published>
</entry>

<entry>
    <id>tag:bradchoate.com,2006://4.2522-comment:22233</id>
    <thr:in-reply-to ref="tag:bradchoate.com,2006://4.2522" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash"/>
 
    <link rel="alternate" type="text/html" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash#c22233" />
    <title>Comment from Anonymous coward on 2007-03-01</title>
    <author>
        <name>Anonymous coward</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>This only works if you crack open a fresh terminal everyday right? I've had the same terminal open for about 3 weeks now...</p>]]>
    </content>
    <published>2007-03-01T11:27:22Z</published>
</entry>

<entry>
    <id>tag:bradchoate.com,2006://4.2522-comment:22235</id>
    <thr:in-reply-to ref="tag:bradchoate.com,2006://4.2522" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash"/>
 
    <link rel="alternate" type="text/html" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash#c22235" />
    <title>Comment from scruzia on 2007-03-03</title>
    <author>
        <name>scruzia</name>
        <uri>http://tmp.i.am</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://tmp.i.am">
        <![CDATA[<p>I usually have 3 to 5 terminal windows open at once.  Does Bash manage to share a history file in that situation?  Zsh doesn't (as of v4.2.3 on Mac OS X).  So here's what I ended up doing in one of my zsh startup files:<br />
<p><pre><br />
tdc_day=$( tdc_sh | sed 's/_.*//' )  # my date stamper<br />
tty=$( tty | sed 's,/dev/,,' )   # tty always prepends the useless "/dev/".<br />
export HISTFILE=$h/zsh.histories/zh.$tdc_day.$tty<br />
export HISTSIZE=100000<br />
</pre><br />
Google for "gigo beh" to see more about my date stamp format.</p></p>]]>
    </content>
    <published>2007-03-03T08:44:41Z</published>
</entry>

<entry>
    <id>tag:bradchoate.com,2006://4.2522-comment:33217</id>
    <thr:in-reply-to ref="tag:bradchoate.com,2006://4.2522" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash"/>
 
    <link rel="alternate" type="text/html" href="http://bradchoate.com/weblog/2006/05/19/daily-history-files-for-bash#c33217" />
    <title>Comment from bronosky.com on 2008-08-20</title>
    <author>
        <name>bronosky.com</name>
        <uri>http://bronosky.com/</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://bronosky.com/">
        <![CDATA[<p>Find HISTTIMEFORMAT on http://www.gnu.org/software/bash/manual/bashref.html#Bash-History-Facilities</p>

<p>That var, if set will cause every [new] line in HISTFILE to be prefaced with a line that looks like the result of:<br />
echo "#$(date +%s)"<br />
Regardless of the format of HISTTIMEFORMAT.  The bash builtin history command will use that format to display the date for each command.  No whitespace is added, so you must put it in your format.  I use:<br />
export HISTSIZE=10000<br />
export HISTTIMEFORMAT="%F-%T%t"<br />
shopt -s histappend</p>

<p>I use a cron job to sweep old commands into an archive.  I have a similar approach to vim.  I can tell you every command I've executed and every file I've saved since the dawn of time.</p>]]>
    </content>
    <published>2008-08-20T14:29:18Z</published>
</entry>


</feed>