<?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>Jetpack Flight Log &#187; zsh</title>
	<atom:link href="http://jetpackweb.com/blog/tags/zsh/feed/" rel="self" type="application/rss+xml" />
	<link>http://jetpackweb.com/blog</link>
	<description>Rock{et}ing the interweb</description>
	<lastBuildDate>Wed, 19 May 2010 22:21:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Pimp your $PS1 with source control information</title>
		<link>http://jetpackweb.com/blog/2010/01/08/pimp-your-ps1-with-source-control-information/</link>
		<comments>http://jetpackweb.com/blog/2010/01/08/pimp-your-ps1-with-source-control-information/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 02:17:09 +0000</pubDate>
		<dc:creator>Brian Racer</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[cvs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://jetpackweb.com/blog/?p=623</guid>
		<description><![CDATA[I recently found a useful tip of appending source control information of the current working directory to your shell&#8217;s $PS1 line. It might look something like the following image: The method I saw suggested using vcprompt, a small program that outputs a short string basic version control info. Although it worked well, there were a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently found a useful tip of appending source control information of the current working directory to your shell&#8217;s $PS1 line. It might look something like the following image:</p>
<p><img src="http://jetpackweb.com/blog/wp-content/uploads/2010/01/Screenshot-Terminal.png" /></p>
<p> The method I saw suggested using <a href="http://vc.gerg.ca/hg/vcprompt/" target="_blank">vcprompt</a>, a small program that outputs a short string basic version control info. Although it worked well, there were a couple issues I had with it. First, it&#8217;s subversion support was somewhat lacking. Second, it was written in C which made it more of a pain to modify, and I wasn&#8217;t a huge fan of keeping the binary in version control. </p>
<p>After a little searching I stumbled across <a href="http://github.com/xvzf/vcprompt">vcprompt.py</a>, a python script that did the same thing. This version also had wider support for source control systems, and being a standard python text script it was something I could easily modify and put into my <a href="http://github.com/anveo/dotfiles" target="_blank">dotfiles</a> git repo. I wasn&#8217;t happy with how this one displayed subversion information either(just a revision number which I didn&#8217;t find very helpful), so I <a href="http://github.com/anveo/dotfiles/blob/master/scripts/vcprompt.py" target="_blank"><strong>made my own modification</strong></a> to display the branch you are in. Please pardon my lacking Python skills. </p>
<p>Anyway, on to pimping your prompt. Before we modify the PS1 variable, we need to make sure the vcprompt.py is in your $PATH. I like to put scripts like this in a custom  <i>bin</i> directory in my homedir. One way to accomplish that might be the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;">$ <span class="kw2">mkdir</span> <span class="re5">-p</span> ~<span class="sy0">/</span>bin
$ <span class="kw3">cd</span> ~<span class="sy0">/</span>bin
$ <span class="kw2">wget</span> http:<span class="sy0">//</span>github.com<span class="sy0">/</span>anveo<span class="sy0">/</span>dotfiles<span class="sy0">/</span>raw<span class="sy0">/</span>master<span class="sy0">/</span>scripts<span class="sy0">/</span>vcprompt.py
$ <span class="kw2">chmod</span> +x vcprompt.py
$ <span class="kw3">export</span> <span class="re2">PATH</span>=~<span class="sy0">/</span>bin:<span class="re1">$PATH</span></pre></div></div>

<p>Displayed next is the PS1 line I use &#8211; it takes up two lines: the first line contains the current user, hostname,  current working directory, and possibly version control info, and the second is just a nice looking arrow for my input. Your terminal will need to support Unicode if you want to use that symbol.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;"><span class="co0"># .bashrc</span>
<span class="re2">PS1</span>=<span class="st0">&quot;<span class="es1">\n</span>\u@\h:\w \[\e[1;30m\]<span class="es4">$(vcprompt)</span>\[\e[0m\] <span class="es1">\n</span>→&quot;</span>
&nbsp;
<span class="co0"># If you are using zsh you may also need the following in .zshrc</span>
setopt prompt_subst</pre></div></div>

<p><small>If you use the colors specified, you may need to <a href="http://github.com/anveo/dotfiles/blob/master/bash/config" target="_blank">define those too</a>.</small></p>
<p>You should now have a prompt similar to the image above! For more shell customizations checkout the rest of my <a href="http://github.com/anveo/dotfiles" target="_blank">dotfiles</a>, and consider buying Peepcode&#8217;s <a href="http://peepcode.com/products/advanced-command-line" target="_blank">Advanced Command Line screencasts</a> for more productive tips!</p>
]]></content:encoded>
			<wfw:commentRss>http://jetpackweb.com/blog/2010/01/08/pimp-your-ps1-with-source-control-information/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
