<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Samsarin</title>
	
	<link>http://www.samsarin.com/blog</link>
	<description>Chris Pettitt's Blog</description>
	<lastBuildDate>Mon, 27 Feb 2012 15:24:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Samsarin" /><feedburner:info uri="samsarin" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Samsarin</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/Samsarin" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2FSamsarin" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>Copying the GNU screen buffer to the Leopard clipboard</title>
		<link>http://feedproxy.google.com/~r/Samsarin/~3/17X35qkTwUs/</link>
		<comments>http://www.samsarin.com/blog/2008/10/18/copying-gnu-screen-buffer-to-leopard-clipboard/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 16:13:58 +0000</pubDate>
		<dc:creator>Chris Pettitt</dc:creator>
				<category><![CDATA[Mac OSX]]></category>

		<guid isPermaLink="false">http://www.samsarin.com/blog/?p=40</guid>
		<description><![CDATA[Quite a while back I wrote an article about how I use GNU screen&#8217;s scrollback buffer. In the article I detailed how to copy the scrollback buffer into the Mac clipboard, which made it easy to copy data to other Mac applications. Unfortunately, I recently moved to Leopard and discovered this no longer works. In [...]]]></description>
			<content:encoded><![CDATA[<p>Quite a while back I wrote an article about how I use <a href="http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/">GNU screen&#8217;s scrollback buffer</a>. In the article I detailed how to copy the scrollback buffer into the Mac clipboard, which made it easy to copy data to other Mac applications. Unfortunately, I recently moved to Leopard and discovered this no longer works. In this short article I will explain an updated procedure that works for Leopard.</p>
<p><span id="more-40"></span></p>
<h2>The Problem</h2>
<p>In Leopard, both pbcopy and pbpaste appear to crash when run from GNU screen. I did some basic investigation and found that pbcopy and pbpaste work by talking to a daemon called pboard, which is managed by launchd in Leopard. Any subprocess launched by GNU screen seems to be unable to talk to pboard, though pbcopy does work with a pboard instance launched from within screen. Unfortunately this defeats the purpose because the pboard instance launched in screen does not work with the OS.</p>
<p>I was not successful in uncovering the reason that pbcopy in screen can&#8217;t talk to the pboard process started by launchd. If anyone knows why this is the case I would be very, very happy to hear about it.</p>
<h2>My Solution</h2>
<p>I realized that if I could somehow get pbcopy running in screen to talk to the pboard running outside of screen then I could write to the Leopard clipboard from screen. The solution I came up with is to start a process outside of screen that listens on a UNIX domain socket. When it receives a message it copies it to the Leopard clipboard using pbcopy. Within screen I use a client that pushes screen&#8217;s /tmp/screen-exchange file over the UNIX domain socket.</p>
<p>Here are the scripts:</p>
<ul>
<li><a href="http://www.samsarin.com/blog/files/uploads/2008/10/pboard_server">pboard_server</a></li>
<li><a href="http://www.samsarin.com/blog/files/uploads/2008/10/pboard_client">pboard_client</a></li>
</ul>
<p>You will need to <code>chmod 755 pboard_server pboard_client</code> after downloading them. To use the new pboard client, add the following to your <code>.screenrc</code>:</p>
<p><code>bind b eval "writebuf" "exec ruby pboard_client"</code></p>
<p>If you used my previous tutorial, the line above should replace the old <code>bind b ...</code> line.</p>
<p>Now when you open a terminal (outside of screen), run <code>pboard_server &amp;</code>. This will start the process that listens for requests over the socket. You only need to do this once when you login, and you could automate this using launchd or some shell scripting from your .bashrc.</p>
<p>You should now be able to start screen and copy to the clipboard!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samsarin.com/blog/2008/10/18/copying-gnu-screen-buffer-to-leopard-clipboard/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://www.samsarin.com/blog/2008/10/18/copying-gnu-screen-buffer-to-leopard-clipboard/</feedburner:origLink></item>
		<item>
		<title>GNU Screen: Working with the Scrollback Buffer</title>
		<link>http://feedproxy.google.com/~r/Samsarin/~3/QQ4TWGhJkCo/</link>
		<comments>http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/#comments</comments>
		<pubDate>Sun, 11 Mar 2007 21:59:04 +0000</pubDate>
		<dc:creator>Chris Pettitt</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[Mac OSX]]></category>

		<guid isPermaLink="false">http://samsarin.com/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/</guid>
		<description><![CDATA[GNU Screen is a UNIX tool that allows multiple console applications to be run, each in its own &#8220;window&#8221;, from the same terminal. In a single Screen session, you can run interactive shells, mail programs, SSH sessions, and other console based applications, and you can easily switch between these using hotkeys. You can even split [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gnu.org/software/screen/">GNU Screen</a> is a UNIX tool that allows multiple console applications to be run, each in its own &#8220;window&#8221;, from the same terminal. In a single Screen session, you can run interactive shells, mail programs, SSH sessions, and other console based applications, and you can easily switch between these using hotkeys. You can even split up the Screen display so that multiple Screen windows can be viewed at the same time.</p>
<p>If you&#8217;ve never used Screen, but frequently use console applications, it is definitely a tool worth exploring. An <a href="http://www.kuro5hin.org/story/2004/3/9/16838/14935">introduction to Screen</a> can be found on the Kuro5hin website.</p>
<p>In this article I share my experience with one of my favorite screen features: its scrollback buffer. As you interact with a Screen window, Screen stores a configurable number of lines of history in its scrollback buffer. The scrollback buffer makes it easy to browse or even search through the history of your windows. In addition, it makes it easy to copy and paste any section of text from the history.</p>
<p><span id="more-7"></span></p>
<h2>Configuring the Scrollback Buffer</h2>
<p>By default, the scrollback buffer only keeps the last 100 lines of text, which is not enough for my typical interaction with Screen. I&#8217;ve found a setting of 5000 lines to be more than adequate for my usage. The number of scrollback lines can be configured in your <em>$HOME/.screenrc</em> file, by adding the following line:</p>
<pre>defscrollback 5000</pre>
<p>This sets the scrollback to 5000 lines.</p>
<p>You can also override this default value when starting screen using the <em>-h [num]</em> option, where <em>num</em> is the number of scrollback lines.</p>
<p>Finally, if you want to change the number of lines of scrollback for a single window, using the &#8220;scrollback&#8221; command. Hit <em>C-a (Ctrl-A) :</em> to go to the Screen command line and type <em>scrollback num</em>, where <em>num</em> is the number of scrollback lines.</p>
<p>You can check the number of scrollback lines in your window. Hit <em>C-a i</em> to display window information. You will see a status line with information similar to the following:</p>
<pre>(27,42)/(186,42)+20 +flow UTF-8 3(bash)</pre>
<p>In this case, my scrollback is 20 lines (it is displayed as +20 in the output above).</p>
<h2>Entering Scrollback Mode and Navigating</h2>
<p>To enter scrollback hit <em>C-a [</em>. A status line will indicate that you've entered copy mode. To exit scrollback mode, hit the <em>escape</em> button.</p>
<p>Navigating in scrollback mode will be pretty familiar to VI users. Here are some of the most common navigation keys (taken from the screen manpage):</p>
<pre>h -    Move the cursor left by one character
j -    Move the cursor down by one line
k -    Move the cursor up by one line
l -    Move the cursor right by one character
0 -    Move to the beginning of the current line
$ -    Move to the end of the current line.
G -    Moves to the specified line
       (defaults to the end of the buffer).
C-u -  Scrolls a half page up.
C-b -  Scrolls a full page up.
C-d -  Scrolls a half page down.
C-f -  Scrolls the full page down.</pre>
<p>I often use the page up and page down commands to quickly scroll back through the window's history.</p>
<p>In addition to traditional navigation, Screen allows you to search the scrollback buffer using the following commands:</p>
<pre>/ -    Search forward
? -    Search backward</pre>
<p>Search is a very useful feature. For example, you could run a script and search for keywords in the output (such as Error), without having to redirect the output.</p>
<h2>Copy and Paste</h2>
<p>Scrollback mode is also know as copy mode and it allows you to copy any section of text into a copy buffer. To copy text, move the cursor to the start of the text you want to copy, hit <em>spacebar</em>, move the cursor to the end of the text you want to copy (Screen will highlight the text to be copied as you move), and again hit <em>spacebar</em>. Screen will indicate the number of characters copied into the copy buffer.</p>
<p>To paste text, simply hit <em>C-a ]</em>.</p>
<h2>Copying to the Mac Clipboard</h2>
<p>While copying and pasting in a terminal is very useful, I also find that I often want to copy some text from a terminal into my clipboard. This next tip will show you how to do this for Mac OSX, but I&#8217;m sure it can be easily modified to work with other operating systems.</p>
<p>Open <em>$HOME/.screenrc</em> and add the following line:</p>
<pre>bind b eval "writebuf" "exec sh -c 'pbcopy &lt; /tmp/screen-exchange'"</pre>
<p>This line tells Screen to write its copy buffer to a temporary file (defaults to <em>/tmp/screen-exchange</em>), and then sends that file to <em>pbcopy</em>, a Mac OSX utility that copies text into the Mac clipboard. In this case, I&#8217;ve bound the command to <em>C-a b</em>, but you can change to best suit your own environment.</p>
<h2>Conclusion</h2>
<p>This wraps up my review of Screen&#8217;s scrollback buffer. I hope this tutorial is useful, especially to those that frequently work in terminal windows.</p>
<p>Do you have interesting ways of using Screen&#8217;s scrollback buffer, or Screen in general?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/feed/</wfw:commentRss>
		<slash:comments>64</slash:comments>
		<feedburner:origLink>http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/</feedburner:origLink></item>
	</channel>
</rss>

