<?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>Chip's Tips for Developers » Perl</title>
	
	<link>http://www.chipstips.com</link>
	<description>Contains coding, but not narcotic.</description>
	<lastBuildDate>Mon, 04 Feb 2013 20:50:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ChipsTipsPerl" /><feedburner:info uri="chipstipsperl" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>url-picker can now count backwards</title>
		<link>http://feedproxy.google.com/~r/ChipsTipsPerl/~3/fnX55t35p2E/</link>
		<comments>http://www.chipstips.com/?p=623#comments</comments>
		<pubDate>Sun, 04 Sep 2011 02:24:07 +0000</pubDate>
		<dc:creator>Sterling Camden</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[plurlpicker]]></category>
		<category><![CDATA[urxvt]]></category>

		<guid isPermaLink="false">http://www.chipstips.com/?p=623</guid>
		<description><![CDATA[Antoine Amarilli emailed me to suggest an enhancement to my url-picker extension for urxvt: number the URLs in reverse order, so that the most recently displayed URL will always be number 1. His rationale is that in a terminal window, you&#8217;re usually focused on what has been displayed last, and being able to use the [...]]]></description>
				<content:encoded><![CDATA[<div class="socialize-in-content socialize-in-content-right"><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://www.chipstips.com/?p=623"></g:plusone></div><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.chipstips.com/?p=623" data-text="url-picker can now count backwards" data-count="vertical" data-via="socializeWP" ><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.chipstips.com%2F%3Fp%3D623&amp;send=&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">
			<!-- 
			reddit_url = "http://www.chipstips.com/?p=623";
			reddit_title = "url-picker can now count backwards";	//-->
		</script><script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">var dzone_url = "http://www.chipstips.com/?p=623";</script>
		<script type="text/javascript">var dzone_title = "url-picker can now count backwards";</script>
		<script type="text/javascript">
			<!-- 
			var dzone_style = "1";
			//-->
		</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></div></div><p><img src="http://chipstips.com/images/plurlpicker001.png" alt="the pick..." align="right" /></p>
<p>Antoine Amarilli emailed me to suggest an enhancement to my url-picker extension for urxvt:  number the URLs in reverse order, so that the most recently displayed URL will always be number 1.  His rationale is that in a terminal window, you&#8217;re usually focused on what has been displayed last, and being able to use the same set of keystrokes to launch the most recently seen URL allows the action to become somewhat automatic.</p>
<p>I liked Antoine&#8217;s suggestion, but I decided not to change the default behavior.  I, for one, find the ascending order makes more sense when viewing my feeds in mutt, because my rss-to-email mechanism adds the item&#8217;s web link as a custom header, so it&#8217;s always the first link on the page.  So, I decided to add a resource to control the order.  If you want descending numbering, add this to your .Xdefaults (or other resource source):</p>
<p><code>URxvt.url-picker.order: descending</code></p>
<p>Now you can always launch the last one with the same finger!</p>
<div class="downloadbuttons">
    <a href="http://bitbucket.org/sterlingcamden/urlpicker"><img src="http://www.chipstips.com/images/bitbucket.png" alt="BitBucket repository" /></a><br />
    <a href="http://www.chipstips.com/download/urlpicker.tar.bz2"><img src="http://www.chipstips.com/images/tarball.png" alt="tarball" /></a>
</div>
<img src="http://feeds.feedburner.com/~r/ChipsTipsPerl/~4/fnX55t35p2E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chipstips.com/?feed=rss2&amp;p=623</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.chipstips.com/?p=623</feedburner:origLink></item>
		<item>
		<title>url-picker extension for urxvt now handles wrapped URLs</title>
		<link>http://feedproxy.google.com/~r/ChipsTipsPerl/~3/MOi1qSGyTpI/</link>
		<comments>http://www.chipstips.com/?p=616#comments</comments>
		<pubDate>Mon, 04 Jul 2011 00:24:16 +0000</pubDate>
		<dc:creator>Sterling Camden</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[plurlpicker]]></category>
		<category><![CDATA[urxvt]]></category>

		<guid isPermaLink="false">http://www.chipstips.com/?p=616</guid>
		<description><![CDATA[Craig Balding emailed me about a &#8220;feature&#8221; that had already plagued me for some time in my url-picker extension for urxvt. Whenever a URL wrapped to a second line, url-picker would only see the portion on the first line. In many cases this only truncated useless parameters that you probably didn&#8217;t want to include anyway [...]]]></description>
				<content:encoded><![CDATA[<div class="socialize-in-content socialize-in-content-right"><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.chipstips.com/?p=616" data-text="url-picker extension for urxvt now handles wrapped URLs" data-count="vertical" data-via="socializeWP" ><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.chipstips.com%2F%3Fp%3D616&amp;send=&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">
			<!-- 
			reddit_url = "http://www.chipstips.com/?p=616";
			reddit_title = "url-picker extension for urxvt now handles wrapped URLs";	//-->
		</script><script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">var dzone_url = "http://www.chipstips.com/?p=616";</script>
		<script type="text/javascript">var dzone_title = "url-picker extension for urxvt now handles wrapped URLs";</script>
		<script type="text/javascript">
			<!-- 
			var dzone_style = "1";
			//-->
		</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></div></div><p>Craig Balding emailed me about a &#8220;feature&#8221; that had already plagued me for some time in my <a href="http://chipstips.com/?tag=plurlpicker">url-picker extension for urxvt</a>.  Whenever a URL wrapped to a second line, url-picker would only see the portion on the first line.  In many cases this only truncated useless parameters that you probably didn&#8217;t want to include anyway (I&#8217;m, looking at you, Facebook).  But often some meaningful bits got truncated, forcing the user to resort to copy/paste.  Not good.</p>
<p>In order to fix this, I had to change the way url-picker loops through the text.  Instead of looking at the text row by row, I now gather all of the text to be considered into a single string in which to search for URLs.  Because we&#8217;re dealing with Unicode here (that&#8217;s one of the reasons for using urxvt to begin with) I can&#8217;t calculate row and column by performing any clever math on the resulting offset.  So instead, I build a hash of row => [start,end] and then search the hash for the offset of any URLs I find.  Seems to work (after I refreshed my memory YET AGAIN on the syntax for Perl array references within hashes), but let me know if you encounter any difficulties.</p>
<p><img src="http://chipstips.com/images/plurlpicker001.png" alt="the pick..." align="right" /></p>
<p>Now you can pick and launch even bigger ones!</p>
<p>Of course, you have to make sure that your terminal display doesn&#8217;t interrupt the URL in other ways.  For example, for <a href="http://mutt.org">mutt</a> you&#8217;d want to have the following in your .muttrc file:</p>
<p><code>set markers=no</code></p>
<p>Otherwise, you&#8217;ll get a &#8220;+&#8221; embedded at the beginning of each wrapped line. </p>
<div class="downloadbuttons">
    <a href="http://bitbucket.org/sterlingcamden/urlpicker"><img src="http://www.chipstips.com/images/bitbucket.png" alt="BitBucket repository" /></a><br />
    <a href="http://www.chipstips.com/download/urlpicker.tar.bz2"><img src="http://www.chipstips.com/images/tarball.png" alt="tarball" /></a>
</div>
<img src="http://feeds.feedburner.com/~r/ChipsTipsPerl/~4/MOi1qSGyTpI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chipstips.com/?feed=rss2&amp;p=616</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chipstips.com/?p=616</feedburner:origLink></item>
		<item>
		<title>Urxvi — keyboard navigation for rxvt-unicode (urxvt)</title>
		<link>http://feedproxy.google.com/~r/ChipsTipsPerl/~3/-MfOOBe_Cug/</link>
		<comments>http://www.chipstips.com/?p=588#comments</comments>
		<pubDate>Mon, 03 Jan 2011 01:26:22 +0000</pubDate>
		<dc:creator>Sterling Camden</dc:creator>
				<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[plurxvi]]></category>
		<category><![CDATA[slips]]></category>
		<category><![CDATA[urxvt]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://www.chipstips.com/?p=588</guid>
		<description><![CDATA[I really like the rxvt-unicode (urxvt) terminal window for X11. I&#8217;ve been extending it a lot for my own needs. There&#8217;s only one glaring piece of functionality that seems to require the mouse: scrolling and selecting text. I thought I&#8217;d remedy that. In my ideal world, I&#8217;d be able to press Scroll Lock, and then [...]]]></description>
				<content:encoded><![CDATA[<div class="socialize-in-content socialize-in-content-right"><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://www.chipstips.com/?p=588"></g:plusone></div><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.chipstips.com/?p=588" data-text="Urxvi &#8212; keyboard navigation for rxvt-unicode (urxvt)" data-count="vertical" data-via="socializeWP" ><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.chipstips.com%2F%3Fp%3D588&amp;send=&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">
			<!-- 
			reddit_url = "http://www.chipstips.com/?p=588";
			reddit_title = "Urxvi &#8212; keyboard navigation for rxvt-unicode (urxvt)";	//-->
		</script><script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">var dzone_url = "http://www.chipstips.com/?p=588";</script>
		<script type="text/javascript">var dzone_title = "Urxvi &#8212; keyboard navigation for rxvt-unicode (urxvt)";</script>
		<script type="text/javascript">
			<!-- 
			var dzone_style = "1";
			//-->
		</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></div></div><p>I really like the <a href="http://software.schmorp.de/pkg/rxvt-unicode.html">rxvt-unicode (urxvt)</a> terminal window for X11.  I&#8217;ve been <a href="http://chipstips.com/?tag=urxvt">extending it a lot</a> for my own needs.  There&#8217;s only one glaring piece of functionality that seems to require the mouse:  scrolling and selecting text.  I thought I&#8217;d remedy that.</p>
<p>In my ideal world, I&#8217;d be able to press Scroll Lock, and then use vi key bindings to move the cursor around, scroll back in the history, and select text for the clipboard without ever touching the mouse.  When I&#8217;m done, Escape or Scroll Lock again should take me back to normal terminal operation.</p>
<p>So be it.  If you install the extension from one of the links below, that&#8217;s what you get out of the box.  That&#8217;s why I called it &#8220;urxvi&#8221;.</p>
<p>But!  I know that some of my keyboard-centric brothers and sisters live on the other side of the denominational divide known as the editor wars, preferring emacs or some other editor.  Thus, I have made urxvi&#8217;s key bindings and behavior completely configurable.  All you have to do is provide your own rcfile for the purpose.  I&#8217;ve even provided the default bindings through a global rcfile (urxvirc), to serve as a starting point.</p>
<p>I probably went a little overboard on the scripting language used in the rcfile.</p>
<p>I call it Slips, for &#8220;Sloppy Lisp.&#8221;  It&#8217;s an S-expression syntax, but with not so much punctuation as Lisp.  It includes a lot of neat features (like lamdbas and witheringly lazy evaluation), along with a lot of glaring omissions (like list processing and I/O).  It&#8217;s basically everything I needed to create the default key bindings, plus a few extras.  I&#8217;ll add functionality to this mini-language as it&#8217;s required.</p>
<p>Implementing a pseudo-Lisp interpreter in Perl brought me closer in tune with <a href="http://xkcd.com/224/">the true nature of the Universe</a>, especially since I did it in such a sloppy fashion.  This certainly isn&#8217;t <a href="http://weblog.raganwald.com/2008/02/turtles-all-way-down-please.html">turtles all the way down</a> &#8212; more like turtles afraid to reach second base.  Actually, I was surprised at how well Perl served this purpose, especially considering my own lack of Perl-fu.</p>
<div class="downloadbuttons">
    <a href="http://bitbucket.org/sterlingcamden/urxvi"><img src="http://www.chipstips.com/images/bitbucket.png" alt="BitBucket repository" /></a><br />
    <a href="http://www.chipstips.com/download/urxvi.tar.bz2"><img src="http://www.chipstips.com/images/tarball.png" alt="tarball" /></a>
</div>
<img src="http://feeds.feedburner.com/~r/ChipsTipsPerl/~4/-MfOOBe_Cug" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chipstips.com/?feed=rss2&amp;p=588</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://www.chipstips.com/?p=588</feedburner:origLink></item>
		<item>
		<title>Bidirectional text display for urxvt</title>
		<link>http://feedproxy.google.com/~r/ChipsTipsPerl/~3/eOeuj4yexSw/</link>
		<comments>http://www.chipstips.com/?p=584#comments</comments>
		<pubDate>Mon, 20 Dec 2010 00:22:41 +0000</pubDate>
		<dc:creator>Sterling Camden</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[bidi]]></category>
		<category><![CDATA[fribidi]]></category>
		<category><![CDATA[plurxvtbidi]]></category>
		<category><![CDATA[urxvt]]></category>

		<guid isPermaLink="false">http://www.chipstips.com/?p=584</guid>
		<description><![CDATA[I received an email message a while back in which the signature included the author&#8217;s name in both Latin and Hebrew characters. I was pleased to see the Hebrew characters rendered properly in my mutt session, having recently reconciled my terminal window with Unicode. However, having studied Hebrew in college, I could see immediately that [...]]]></description>
				<content:encoded><![CDATA[<div class="socialize-in-content socialize-in-content-right"><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://www.chipstips.com/?p=584"></g:plusone></div><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.chipstips.com/?p=584" data-text="Bidirectional text display for urxvt" data-count="vertical" data-via="socializeWP" ><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.chipstips.com%2F%3Fp%3D584&amp;send=&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">
			<!-- 
			reddit_url = "http://www.chipstips.com/?p=584";
			reddit_title = "Bidirectional text display for urxvt";	//-->
		</script><script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">var dzone_url = "http://www.chipstips.com/?p=584";</script>
		<script type="text/javascript">var dzone_title = "Bidirectional text display for urxvt";</script>
		<script type="text/javascript">
			<!-- 
			var dzone_style = "1";
			//-->
		</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></div></div><p>I received an email message a while back in which the signature included the author&#8217;s name in both Latin and Hebrew characters.  I was pleased to see the Hebrew characters rendered properly in my mutt session, having <a href="http://www.chipstips.com/?p=576">recently reconciled my terminal window with Unicode</a>.  However, having studied Hebrew in college, I could see immediately that the Hebrew text was being displayed left-to-right instead of the usual right-to-left.</p>
<p>I brought this to the author&#8217;s attention, thinking that he should swap the characters in his signature.  It turns out, though, that Unicode has <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Bi-directional_text">an algorithm for supporting bidirectional display</a> of mixed text that is presented in logical, as opposed to visual, order.</p>
<p>Next stop: my terminal window, rxvt-unicode (aka urxvt), which makes Unicode part of its name, should know how to handle this, right?  In the man page we find:</p>
<blockquote><p>
A somewhat difficult case are right-to-left scripts, such as hebrew: rxvt-unicode adopts the view that bidirectional algorithms belong in the application, not the terminal emulator (too many things &#8212; such as cursor-movement while editing &#8212; break otherwise), but that might change.
</p></blockquote>
<p>Hrumph.  I don&#8217;t think so.  Should vim, and mutt, and cat, and every other application have to reorder text as it&#8217;s being displayed (but not, presumably, as it&#8217;s being piped)?  No, I think this needs to happen at the visual vehicle itself:  the terminal window.</p>
<p>Fortunately, urxvt sports a fine extension mechanism using Perl, and it just so happens that <a href="http://search.cpan.org/~kamensky/Text-Bidi-0.03/lib/Text/Bidi.pm">a Perl module for bidirectional support</a> is available.  It gives some warnings on FreeBSD using Perl 5.12.2, but since stderr is not usually visible for urxvt, I decided to use it anyway.  You can download the extension I created from one of the links at the bottom of this post.  See the README for details.  I constructed this extension so you can enable and disable it by a keystroke, and you can also specify the initial state.</p>
<p>It isn&#8217;t perfect.  When editing or entering text, you probably want to turn it off to avoid confusion &#8212; but then you can turn it on and do a quick Ctrl+L in vim or mutt to see the result.</p>
<p>Good luck &#8212; מזל טוב</p>
<div class="downloadbuttons">
    <a href="http://bitbucket.org/sterlingcamden/urxvt-bidi"><img src="http://www.chipstips.com/images/bitbucket.png" alt="BitBucket repository" /></a><br />
    <a href="http://www.chipstips.com/download/urxvt-bidi.tar.bz2"><img src="http://www.chipstips.com/images/tarball.png" alt="tarball" /></a>
</div>
<img src="http://feeds.feedburner.com/~r/ChipsTipsPerl/~4/eOeuj4yexSw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chipstips.com/?feed=rss2&amp;p=584</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.chipstips.com/?p=584</feedburner:origLink></item>
		<item>
		<title>Put this in your pipe and smoke it, urxvt</title>
		<link>http://feedproxy.google.com/~r/ChipsTipsPerl/~3/VnD_Vj6CkY8/</link>
		<comments>http://www.chipstips.com/?p=582#comments</comments>
		<pubDate>Sat, 18 Dec 2010 05:54:37 +0000</pubDate>
		<dc:creator>Sterling Camden</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[pipe]]></category>
		<category><![CDATA[plurxvtpipe]]></category>
		<category><![CDATA[urxvt]]></category>

		<guid isPermaLink="false">http://www.chipstips.com/?p=582</guid>
		<description><![CDATA[Most desktop systems provide means for copying text from one application to another, and X11 is no exception. In most windows, you just highlight the text with the mouse, then either middle-click where you want to paste it or press Shift-Insert. I hate having to reach for the mouse, however. I&#8217;d like to be able [...]]]></description>
				<content:encoded><![CDATA[<div class="socialize-in-content socialize-in-content-right"><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://www.chipstips.com/?p=582"></g:plusone></div><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.chipstips.com/?p=582" data-text="Put this in your pipe and smoke it, urxvt" data-count="vertical" data-via="socializeWP" ><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.chipstips.com%2F%3Fp%3D582&amp;send=&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">
			<!-- 
			reddit_url = "http://www.chipstips.com/?p=582";
			reddit_title = "Put this in your pipe and smoke it, urxvt";	//-->
		</script><script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">var dzone_url = "http://www.chipstips.com/?p=582";</script>
		<script type="text/javascript">var dzone_title = "Put this in your pipe and smoke it, urxvt";</script>
		<script type="text/javascript">
			<!-- 
			var dzone_style = "1";
			//-->
		</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></div></div><p>Most desktop systems provide means for copying text from one application to another, and X11 is no exception.  In most windows, you just highlight the text with the mouse, then either middle-click where you want to paste it or press Shift-Insert.  I hate having to reach for the mouse, however.  I&#8217;d like to be able to just pop what I see on the screen into vim with a keystroke, and sort it out from there.</p>
<p>Well, that&#8217;s exactly what I can do now when I&#8217;m using rxvt-unicode (aka urxvt) as my X terminal window.  I&#8217;ve created a Perl extension for urxvt (which you can download from one of the links below) that allows you to map keys to pipe the terminal window&#8217;s text to whatever application you choose.  You can have it grab the selected text, the visible text, or all text (including scrollback).  You can also say, &#8220;take the selected text if there is any, otherwise take the visible text (or all text)&#8221;.  You control these choices by arguments passed to the user command when you set it up in .Xdefaults.  See the README for details.</p>
<p>Here&#8217;s just one scenario where this approach beats other options:  let&#8217;s say I receive an email in German that I want to translate to English.  I could select the text, start up a browser, and paste it into Google translate.  That probably consumed at least a minute.  Or, I could use mutt&#8217;s pipe command and send it to the <a href="http://www.freshports.org/misc/translate/">translate(1) application</a> with the appropriate switches.  But piping or editing messages from mutt has a few drawbacks:  the messages include all headers and attachments, encoding might be strange, and any display-hook would not have been applied.  If you want the text as displayed, you have to resort to copy/paste &#8212; until now.</p>
<p>Now what I do is press Alt-\, which I&#8217;ve mapped to pipe the visible text to vim in another terminal window.  In vim, I press F4, which is mapped to a command to filter the buffer through translate(1) with everything in the command specified except the source language and the final &lt;Return&gt;.  Thus, I type &#8220;de&#8221; (for German) and press Enter.  The text in the buffer is translated from German to English.  Counting the Alt key, that&#8217;s six keystrokes, without taking my hands off the keyboard.</p>
<div class="downloadbuttons">
    <a href="http://bitbucket.org/sterlingcamden/urxvt-pipe"><img src="http://www.chipstips.com/images/bitbucket.png" alt="BitBucket repository" /></a><br />
    <a href="http://www.chipstips.com/download/urxvt-pipe.tar.bz2"><img src="http://www.chipstips.com/images/tarball.png" alt="tarball" /></a>
</div>
<img src="http://feeds.feedburner.com/~r/ChipsTipsPerl/~4/VnD_Vj6CkY8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chipstips.com/?feed=rss2&amp;p=582</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.chipstips.com/?p=582</feedburner:origLink></item>
		<item>
		<title>Enhanced url-picker extension for urxvt</title>
		<link>http://feedproxy.google.com/~r/ChipsTipsPerl/~3/r1ycJAxY84A/</link>
		<comments>http://www.chipstips.com/?p=574#comments</comments>
		<pubDate>Fri, 26 Nov 2010 22:39:29 +0000</pubDate>
		<dc:creator>Sterling Camden</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[plurlpicker]]></category>
		<category><![CDATA[urxvt]]></category>

		<guid isPermaLink="false">http://www.chipstips.com/?p=574</guid>
		<description><![CDATA[I&#8217;ve made the following enhancements to my keyboard-centric URL pick-and-launch extension for urxvt. Scroll down for the download links. Status message on launch The url-picker extension has always launched the URL as soon as it was uniquely qualified, in order to save keystrokes. Depending on the browser, however, it might take a few seconds for [...]]]></description>
				<content:encoded><![CDATA[<div class="socialize-in-content socialize-in-content-right"><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://www.chipstips.com/?p=574"></g:plusone></div><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.chipstips.com/?p=574" data-text="Enhanced url-picker extension for urxvt" data-count="vertical" data-via="socializeWP" ><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.chipstips.com%2F%3Fp%3D574&amp;send=&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">
			<!-- 
			reddit_url = "http://www.chipstips.com/?p=574";
			reddit_title = "Enhanced url-picker extension for urxvt";	//-->
		</script><script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">var dzone_url = "http://www.chipstips.com/?p=574";</script>
		<script type="text/javascript">var dzone_title = "Enhanced url-picker extension for urxvt";</script>
		<script type="text/javascript">
			<!-- 
			var dzone_style = "1";
			//-->
		</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></div></div><p>I&#8217;ve made the following enhancements to my keyboard-centric URL pick-and-launch extension for urxvt.  Scroll down for the download links.</p>
<h4>Status message on launch</h4>
<p>The url-picker extension has always launched the URL as soon as it was uniquely qualified, in order to save keystrokes.  Depending on the browser, however, it might take a few seconds for the user to see that the launch has occurred.  So, I added a status message across the bottom line of the terminal window prior to launching the URL.  This message remains visible for five seconds.  See below for controlling its renditions.</p>
<h4>Restrict search to selected text</h4>
<p>If part of the text of the window is visibly marked for selection, then url-picker will now restrict its search for URLs to that text.  Otherwise, url-picker will use the entire visible portion of the terminal window.  See below for a related correction.</p>
<h4>Correction to search of scrolled text</h4>
<p>I corrected a flaw in the URL search when the user has scrolled the terminal window to make previously invisible text visible again.  That region is now searched and labeled properly.</p>
<h4>Ability to override colors</h4>
<p>I&#8217;ve added some X resources for controlling the colors used in the display of url-picker&#8217;s visible elements.  Each of these takes the form:</p>
<p>URxvt.url-picker.<em>element</em>.foregroundColor<br />
URxvt.url-picker.<em>element</em>.backgroundColor</p>
<p>where <em>element</em> is the name of the url-picker element to control.  These are:</p>
<ul>
<li>input &#8211; the text (numbers) typed by the user</li>
<li>label &#8211; the numbered labels placed over each URL in the window</li>
<li>prompt &#8211; the &#8220;Follow:&#8221; prompt</li>
<li>status &#8211; any status or error messages</li>
</ul>
<p>You must specify the colors using a urxvt color index, as described in the urxvt(1) man page under COLORS AND GRAPHICS.</p>
<p><img src="http://chipstips.com/images/plurlpicker001.png" alt="the pick..." align="right" /><br />
Have fun pickin&#8217; and launchin&#8217;!</p>
<div class="downloadbuttons">
    <a href="http://bitbucket.org/sterlingcamden/urlpicker"><img src="http://www.chipstips.com/images/bitbucket.png" alt="BitBucket repository" /></a><br />
    <a href="http://www.chipstips.com/download/plurlpicker.tar.bz2"><img src="http://www.chipstips.com/images/tarball.png" alt="tarball" /></a>
</div>
<img src="http://feeds.feedburner.com/~r/ChipsTipsPerl/~4/r1ycJAxY84A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chipstips.com/?feed=rss2&amp;p=574</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.chipstips.com/?p=574</feedburner:origLink></item>
		<item>
		<title>Keyboard-centric URL launcher for rxvt-unicode</title>
		<link>http://feedproxy.google.com/~r/ChipsTipsPerl/~3/H5U9K0KNiLg/</link>
		<comments>http://www.chipstips.com/?p=553#comments</comments>
		<pubDate>Sat, 11 Sep 2010 03:55:14 +0000</pubDate>
		<dc:creator>Sterling Camden</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[urxvt]]></category>
		<category><![CDATA[vimperator]]></category>

		<guid isPermaLink="false">http://www.chipstips.com/?p=553</guid>
		<description><![CDATA[The xterm replacement rxvt-unicode (otherwise known as urxvt) has a lot more going for it than fully supporting unicode text. It&#8217;s also scriptable in Perl, and it comes with some useful extensions which you can easily enable as well as learn from them for creating your own. One of these is the &#8216;matcher&#8217; extension, which [...]]]></description>
				<content:encoded><![CDATA[<div class="socialize-in-content socialize-in-content-right"><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://www.chipstips.com/?p=553"></g:plusone></div><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.chipstips.com/?p=553" data-text="Keyboard-centric URL launcher for rxvt-unicode" data-count="vertical" data-via="socializeWP" ><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.chipstips.com%2F%3Fp%3D553&amp;send=&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">
			<!-- 
			reddit_url = "http://www.chipstips.com/?p=553";
			reddit_title = "Keyboard-centric URL launcher for rxvt-unicode";	//-->
		</script><script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">var dzone_url = "http://www.chipstips.com/?p=553";</script>
		<script type="text/javascript">var dzone_title = "Keyboard-centric URL launcher for rxvt-unicode";</script>
		<script type="text/javascript">
			<!-- 
			var dzone_style = "1";
			//-->
		</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></div></div><p>The xterm replacement <a href="http://software.schmorp.de/pkg/rxvt-unicode.html">rxvt-unicode</a> (otherwise known as urxvt) has a lot more going for it than fully supporting unicode text.  It&#8217;s also scriptable in Perl, and it comes with some useful extensions which you can easily enable as well as learn from them for creating your own.  One of these is the &#8216;matcher&#8217; extension, which renders URLs in the terminal window as underlined text, allows you associate a mouse button with launching them to your favorite browser (I chose left-button), and also takes a keyboard sequence for launching.  Unfortunately, the keyboard sequence can only launch the most recently seen URL.</p>
<p>When reading emails or feeds, I frequently want to launch one of the URLs displayed that isn&#8217;t the last one.  I hate having to reach for the mouse, but how could you use the keyboard to efficiently launch one of several URLs on the screen?</p>
<p>Then, during the <a href="http://www.chipsquips.com/?p=2431">FreeBSD Bugathon</a>, I happened to test an upgrade to the xpi-vimperator port.  I love it!  It makes firefox operate like vim, and it&#8217;s highly customizable.  It also provided inspiration for solving my URL conundrum.  <a href="http://vimperator.org/">Vimperator</a> provides a way to do this for web pages.  Type &#8216;f&#8217; and you go into QuickHint mode &#8212; all the possible links on the page are labeled with unique numbers.  When you type one, it&#8217;s launched.</p>
<p>Ah ha!  I could do the same thing for urxvt!  So, I created the Perl extension named url-picker &#8212; see the links at the bottom of the page.  You can map whatever key you like to start it, at which point it labels all the visible URLs and prompts you to start typing a number.  Let me show you what I mean by doing it now, while I&#8217;m editing this post:</p>
<p><img src="http://chipstips.com/images/plurlpicker.png"></p>
<p>As you can see, I use vim for editing my posts (then publish them with <a href="http://chipstips.com/?tag=rbrump">rump</a>).  At the time I took the picture, I had three URLs in the document.  If I press 1, 2, or 3, then that URL will be launched in Firefox (the browser I&#8217;ve configured it to use).</p>
<p>You can pick your friends, you can pick your nose, and now you can pick your URL.</p>
<p>See the README for full details.  Pretty soon I&#8217;ll be able to disconnect the mouse altogether.</p>
<p>UPDATE:  Thanks to my good friend <a href="http://sob.apotheon.org">Chad Perrin</a> for graciously helping me improve my Perl, which has grown rusty through lack of use.</p>
<div class="downloadbuttons">
    <a href="http://bitbucket.org/sterlingcamden/urlpicker"><img src="http://www.chipstips.com/images/bitbucket.png" alt="BitBucket repository" /></a><br />
    <a href="http://www.chipstips.com/download/plurlpicker.tar.bz2"><img src="http://www.chipstips.com/images/tarball.png" alt="tarball" /></a>
</div>
<img src="http://feeds.feedburner.com/~r/ChipsTipsPerl/~4/H5U9K0KNiLg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chipstips.com/?feed=rss2&amp;p=553</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.chipstips.com/?p=553</feedburner:origLink></item>
		<item>
		<title>Debugging Perl scripts on a web server</title>
		<link>http://feedproxy.google.com/~r/ChipsTipsPerl/~3/766fHIMU4QY/</link>
		<comments>http://www.chipstips.com/?p=130#comments</comments>
		<pubDate>Thu, 12 Jan 2006 01:25:06 +0000</pubDate>
		<dc:creator>Sterling Camden</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[pldebug]]></category>

		<guid isPermaLink="false">http://www.chipstips.com/new/?p=130</guid>
		<description><![CDATA[If you&#8217;ve ever worked on a web server that doesn&#8217;t report Perl errors back to the browser, then this script is for you. Not only will it send the errors back to the browser, but also the output of the target script up to the point of failure. All you do is pass the target [...]]]></description>
				<content:encoded><![CDATA[<div class="socialize-in-content socialize-in-content-right"><div class="socialize-in-button socialize-in-button-right"><g:plusone size="tall" href="http://www.chipstips.com/?p=130"></g:plusone></div><div class="socialize-in-button socialize-in-button-right"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.chipstips.com/?p=130" data-text="Debugging Perl scripts on a web server" data-count="vertical" data-via="socializeWP" ><!--Tweetter--></a></div><div class="socialize-in-button socialize-in-button-right"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.chipstips.com%2F%3Fp%3D130&amp;send=&amp;layout=box_count&amp;width=50&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:65px;" allowTransparency="true"></iframe></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">
			<!-- 
			reddit_url = "http://www.chipstips.com/?p=130";
			reddit_title = "Debugging Perl scripts on a web server";	//-->
		</script><script type="text/javascript" src="http://www.reddit.com/static/button/button2.js"></script></div><div class="socialize-in-button socialize-in-button-right"><script type="text/javascript">var dzone_url = "http://www.chipstips.com/?p=130";</script>
		<script type="text/javascript">var dzone_title = "Debugging Perl scripts on a web server";</script>
		<script type="text/javascript">
			<!-- 
			var dzone_style = "1";
			//-->
		</script><script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></div></div><p>If you&#8217;ve ever worked on a web server that doesn&#8217;t report Perl errors back to the browser, then this script is for you.  Not only will it send the errors back to the browser, but also the output of the target script up to the point of failure.  All you do is pass the target script as a &#8220;script&#8221; parameter to cgidebug.pl:</p>
<p><code>http://www.yoururl.com/cgidebug.pl?script=yourscript.pl</code></p>
<p>If you need to pass parameters to your script, just add them as parameters to cgidebug.pl:</p>
<p><code>http://www.yoururl.com/cgidebug.pl?script=yourscript.pl&#038;param1=param1&#038;param2=param2...</code></p>
<div><a href="http://www.chipstips.com/download/pldebug.zip"><img src="http://www.chipstips.com/images/download.gif" /></a></div>
<img src="http://feeds.feedburner.com/~r/ChipsTipsPerl/~4/766fHIMU4QY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chipstips.com/?feed=rss2&amp;p=130</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chipstips.com/?p=130</feedburner:origLink></item>
	</channel>
</rss>
