<?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>Thu, 15 Mar 2012 05:47:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</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 { print $DIRSTACK } function pushd { dirname=$1 cd ${dirname:?"missing directory name."} DIRSTACK="$PWD $DIRSTACK" } function popd { DIRSTACK=${DIRSTACK#* } top=${DIRSTACK%% *} <a href="http://bloggoergosum.com/2007/03/28/ksh-stuff/"> read more <span class="meta-nav">&#187;</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>
<pre lang="Bash">
DIRSTACK=$PWD
function dirs {
  print $DIRSTACK
}

function pushd {
  dirname=$1
  cd ${dirname:?"missing directory name."}
  DIRSTACK="$PWD $DIRSTACK"
}

function popd {
  DIRSTACK=${DIRSTACK#* }
  top=${DIRSTACK%% *}
  cd $top
}

function rfind
{
  dir=$PWD
  while [ ! -e $1 ]; do
    if [ $PWD == "/" ]; then
      command cd $dir
      return 1
    else
      command cd ..
    fi
  done

  rfdir=$PWD
  command cd $dir

  return 0
}

function wt
{
  printf "ESC]0;${@/$HOME/'~'}^G"
}

function git_dir
{
  typeset str
  rfdir=""
  rfind '.git'
  if [ $? -eq 0  ]; then
    str="\{`git branch | grep '*' | cut -d ' ' -f 2`\}"
    wt "[${rfdir}${str}]"
  else
    wt "xterm"
  fi

  echo "$str"
}

function mkprompt
{
  typeset branch

  branch=`git_dir`
  PS1="${branch}$ "
}

function cd
{
  PS1="$ "
  command cd $@
  mkprompt
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bloggoergosum.com/2007/03/28/ksh-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

