<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Bash on iMil.net</title>
    <link>http://imil.net/blog/tags/bash/</link>
    <description>Recent content in Bash on iMil.net</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 30 Apr 2017 14:51:22 +0000</lastBuildDate>
    <atom:link href="http://imil.net/blog/tags/bash/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Tricking bash HISTTIMEFORMAT</title>
      <link>http://imil.net/blog/posts/2017/tricking-bash-histtimeformat/</link>
      <pubDate>Sun, 30 Apr 2017 14:51:22 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2017/tricking-bash-histtimeformat/</guid>
      <description>&lt;p&gt;While trying to find a clean method to remove line numbers from the &lt;code&gt;history&lt;/code&gt; command, I found an interesting trick by using the &lt;code&gt;HISTTIMEFORMAT&lt;/code&gt; environment variable. Here&amp;rsquo;s what &lt;code&gt;bash&lt;/code&gt;&amp;rsquo;s &lt;code&gt;man&lt;/code&gt; says:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       HISTTIMEFORMAT&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              If  this  variable  is  set and not null, its value is used as a&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              format string &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; strftime&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;3&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; to print the time stamp associated&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              with  each  history  entry displayed by the history builtin.  If&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              this variable is set, time stamps are  written  to  the  history&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              file  so they may be preserved across shell sessions.  This uses&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              the history comment character  to  distinguish  timestamps  from&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              other history lines.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But it turns out you can actually put pretty much anything in there, and for example, an &lt;code&gt;ANSI&lt;/code&gt; escape sequence that does a line feed and erases the current line:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
