{"id":40,"date":"2009-07-15T11:20:36","date_gmt":"2009-07-15T16:20:36","guid":{"rendered":"http:\/\/blog.alanporter.com\/2009-07-15\/save-that-thought"},"modified":"2009-07-15T11:20:36","modified_gmt":"2009-07-15T16:20:36","slug":"save-that-thought","status":"publish","type":"post","link":"https:\/\/alanporter.com\/blog\/2009\/07\/15\/save-that-thought\/","title":{"rendered":"Save that thought&#8230;"},"content":{"rendered":"<p>At work, our build process can produce thousands of lines of code, and sometimes the important bits can slide off of the terminal&#8217;s scrollback buffer.<\/p>\n<p>So I created an alias that logs all output of the shell.  It&#8217;s nothing fancy&#8230; it&#8217;s just a call to <code>script<\/code> with an argument to put the time and date in the filename.  But it goes a step further, actually <strong>exec<\/strong>-ing the script command, so you do not have to exit twice when you&#8217;re done (once to exit the script, and once to exit the original shell).<\/p>\n<pre>alias log='exec script \"\/home\/alan\/logs\/terminal-$(date +%Y%m%d-%H%M%S)-$$.log\"'<\/pre>\n<p>Still, this requires you to think about logging before you start your work.<\/p>\n<p>Since I normally launch my shell windows from a Gnome <em>application launcher<\/em> icon, I decided to modify that launcher so that EVERYTHING is logged.<\/p>\n<p>On Gnome, right-click on the panel at the top and select &#8220;+ Add to panel&#8230;&#8221;.  Then select &#8220;application launcher&#8221; and pick out the gnome-terminal from the menus.  You&#8217;ll have a little terminal icon on the top Gnome panel.<\/p>\n<p>Right-click on that terminal icon and select &#8220;properties&#8221;.  It should say &#8220;gnome-terminal&#8221;.  Change it to the following:<\/p>\n<pre>sh -c \"exec gnome-terminal -x script $HOME\/logs\/terminal-$(date +%%Y%%m%%d-%%H%%M%%S)-$$.log\"<\/pre>\n<p>The double-percents are so the launcher will not interpret them.<\/p>\n<p>Now, when you click on that application launcher icon, a new terminal window will open, and all output to that terminal will be logged.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At work, our build process can produce thousands of lines of code, and sometimes the important bits can slide off of the terminal&#8217;s scrollback buffer. So I created an alias that logs all output of the shell. It&#8217;s nothing fancy&#8230; it&#8217;s just a call to script with an argument to put the time and date [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,15],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-software","category-tips-tricks","count-0","even alt","author-alan","last"],"_links":{"self":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/comments?post=40"}],"version-history":[{"count":0,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts\/40\/revisions"}],"wp:attachment":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/media?parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/categories?post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/tags?post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}