<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>bloggo ergo sum &#187; sh</title>
	<atom:link href="http://bloggoergosum.com/tag/sh/feed/" rel="self" type="application/rss+xml" />
	<link>http://bloggoergosum.com</link>
	<description></description>
	<lastBuildDate>Sun, 14 Mar 2010 21:13:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>ksh stuff</title>
		<link>http://bloggoergosum.com/2007/03/28/ksh-stuff/</link>
		<comments>http://bloggoergosum.com/2007/03/28/ksh-stuff/#comments</comments>
		<pubDate>Thu, 29 Mar 2007 01:55:47 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sh]]></category>

		<guid isPermaLink="false">http://bloggoergosum.us/2007/03/28/ksh-stuff/</guid>
		<description><![CDATA[Below is a little code I use with ksh. The wt() function can only be expected to work in an X-term. The code sequences are different for other terminal emulators. DIRSTACK=$PWD function dirs &#123; print $DIRSTACK &#125; &#160; function pushd &#8230; <a href="http://bloggoergosum.com/2007/03/28/ksh-stuff/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Below is a little code I use with ksh.  The wt() function can only be expected to work in an X-term.  The code sequences are different for other terminal emulators.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">DIRSTACK</span>=<span style="color: #007800;">$PWD</span>
<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #7a0874; font-weight: bold;">dirs</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  print <span style="color: #007800;">$DIRSTACK</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #7a0874; font-weight: bold;">pushd</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dirname</span></span>=$<span style="color: #000000;">1</span>
  <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #800000;">${dirname:?&quot;missing directory name.&quot;}</span>
  <span style="color: #007800;">DIRSTACK</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$PWD</span> <span style="color: #007800;">$DIRSTACK</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #7a0874; font-weight: bold;">popd</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #007800;">DIRSTACK</span>=<span style="color: #800000;">${DIRSTACK#* }</span>
  <span style="color: #007800;">top</span>=<span style="color: #800000;">${DIRSTACK%% *}</span>
  <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$top</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> rfind
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #007800;">$PWD</span>
  <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-e</span> $<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$PWD</span> == <span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
      <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$dir</span>
      <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">else</span>
      <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #7a0874; font-weight: bold;">cd</span> ..
    <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
  <span style="color: #007800;">rfdir</span>=<span style="color: #007800;">$PWD</span>
  <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$dir</span>
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wt
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;ESC]0;<span style="color: #007800;">${@/$HOME/'~'}</span>^G&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> git_dir
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">typeset</span> str
  <span style="color: #007800;">rfdir</span>=<span style="color: #ff0000;">&quot;&quot;</span>
  rfind <span style="color: #ff0000;">'.git'</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span>  <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">str</span>=<span style="color: #ff0000;">&quot;\{<span style="color: #780078;">`git branch | grep '*' | cut -d ' ' -f 2`</span>\}&quot;</span>
    wt <span style="color: #ff0000;">&quot;[<span style="color: #007800;">${rfdir}</span><span style="color: #007800;">${str}</span>]&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
    wt <span style="color: #ff0000;">&quot;xterm&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$str</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mkprompt
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">typeset</span> branch
&nbsp;
  <span style="color: #007800;">branch</span>=<span style="color: #000000; font-weight: bold;">`</span>git_dir<span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${branch}</span>$ &quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #7a0874; font-weight: bold;">cd</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #007800;">PS1</span>=<span style="color: #ff0000;">&quot;$ &quot;</span>
  <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #7a0874; font-weight: bold;">cd</span> $<span style="color: #000000; font-weight: bold;">@</span>
  mkprompt
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bloggoergosum.com/2007/03/28/ksh-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
