<?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>Gaurav &#187; vista</title>
	<atom:link href="http://allyourcodearebelongto.me/blog/category/vista/feed/" rel="self" type="application/rss+xml" />
	<link>http://allyourcodearebelongto.me/blog</link>
	<description>All About Everything</description>
	<lastBuildDate>Sun, 23 Nov 2008 19:44:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Multiple ways to open PowerShell in the current Explorer window</title>
		<link>http://allyourcodearebelongto.me/blog/2008/10/14/multiple-ways-to-open-powershell-in-the-current-explorer-window/</link>
		<comments>http://allyourcodearebelongto.me/blog/2008/10/14/multiple-ways-to-open-powershell-in-the-current-explorer-window/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 16:42:35 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[explorer]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[right click]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2008/10/14/multiple-ways-to-open-powershell-in-the-current-explorer-window/</guid>
		<description><![CDATA[

These techniques are generic and can be used for other items like command prompt as well. A word of caution, everything given below involves fiddling with the registry so please backup your system’s registry or create a restore point before trying this out.
1) Adding it to Vista Explorer’s toolbar:
 
This is the most convenient one [...]]]></description>
			<content:encoded><![CDATA[</p>
</p>
<p>These techniques are generic and can be used for other items like command prompt as well. A word of caution, everything given below involves fiddling with the registry so please backup your system’s registry or create a restore point before trying this out.</p>
<h2>1) Adding it to Vista Explorer’s toolbar:</h2>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image11.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb12.png" width="478" height="176"></a> </p>
<p>This is the most convenient one in my opinion, but requires most work to enable it.</p>
<p>Firstly, navigate to the following registry key:</p>
<p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\FolderTypes\{7d49d726-3c21-4f05-99aa-fdc2c9474656}</p>
<p><span id="more-121"></span>
<p>Its should have the following items:</p>
<p><a href="http://techblogging.files.wordpress.com/2008/10/image12.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb13.png" width="381" height="107"></a> </p>
<p>Note that it has following two items:</p>
<ol>
<li><strong>TasksItemsSelected</strong>: Enabled when an item is selected in the view.
<li><strong>TasksNoItemsSelected</strong>: Enabled when nothing is selected in the view.</li>
</ol>
<p>Each of these keys have multiple items inside them each pointing to separate shortcut inside the toolbar.</p>
<p>Import the following registry file so that the PowerShell icon appears in the toolbar:</p>
<p><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/code/vista%20toolbar.reg">Download From Skydrive</a></p>
<p>Before importing I will also point out that I am assuming the a batch file exists at the following path:</p>
<p>C:\\Users\\Gaurav\\Programs\\shortcuts\\psh_launch.bat %2</p>
<p>The content of this file should be:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> @echo off</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span> pushd %1</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span> @echo</pre>
</div>
</div>
<p>You can search and replace the location of this file to your custom location inside the just downloaded registry file. Its being used in two places.</p>
<p>Also, remember to take a backup of this registry key or make a restore point before importing this registry key.</p>
<p>That&#8217;s it. Now a PowerShell Icon should appear inside the every folder.</p>
<p>&nbsp;</p>
</p>
<h2>The PowerShell icon still doesn’t appear?</h2>
<p>Actually the registry file only modifies the folders of <strong>Document Type</strong> and the PowerShell icon will appear only inside folders of <strong>Document Type.</strong></p>
<p>An easy way to make all the folders inside a Drive <strong>Document Type:</strong></p>
<p>right click on drive/partition –&gt; select Properties –&gt; select Customize tab-&gt; and select following options:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image13.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb14.png" width="360" height="160"></a>&nbsp; </p>
<p>So this way we just forced all the folders in the drive to be of <strong>Document Type.</strong></p>
<p>The same procedure can be used to add multiple items on the toolbar. Its a lot of work but the end result is worth it :)</p>
<p>&nbsp;</p>
<h2>2) Using AutoHotKey</h2>
<p><a href="http://www.autohotkey.com/">AutoHotKey</a> is used for creating keyboard macros. </p>
<p>AutoHotKey will use the same batch file that was created to launch PowerShell in the current directory.</p>
<p>Here is the script:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> !p::</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span> IfWinActive ahk_class CabinetWClass</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span> WinGetClass explorerClass, A</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span> ControlGetText currentPath, Edit1, ahk_class %explorerClass%</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span> run C:\\Users\\Gaurav\\Programs\\shortcuts\\psh_launch.bat <span style="color:#006080;">"%currentPath%"</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span> }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span> <span style="color:#0000ff;">return</span></pre>
</div>
</div>
<p>Just fix path to the batch file, save and reload AutoHotKey.</p>
<p>Now press Alt + P to launch PowerShell inside the current explorer window.</p>
<p>&nbsp;</p>
<h2>3) Right Click Menu</h2>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image14.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb15.png" width="480" height="304"></a> </p>
<p>To add PowerShell to right click menu navigate to following registry entry:</p>
<p>HKEY_CLASSES_ROOT\Directory\Background\shell</p>
<p>and create a key with name <strong>powershell</strong> inside shell and a key with name command inside it. Edit the default value of command key to:</p>
<p>C:\Users\Gaurav\Programs\shortcuts\psh_launch.bat &#8220;%V&#8221;</p>
<p>This is same batch file created earlier and the exact path needs to be fixed.</p>
<p>or just import this file into your registry and fix the path to the batch file:</p>
<p><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/code/right-click-powershell.reg">Download from Skydrive</a></p>
<p>That’s it, now PowerShell should show up in you right-click menu inside any directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2008/10/14/multiple-ways-to-open-powershell-in-the-current-explorer-window/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Context sensitive auto-completion using PowerShell, PowerTab and GIT</title>
		<link>http://allyourcodearebelongto.me/blog/2008/10/13/context-sensitive-auto-completion-using-powershell-powertab-and-git/</link>
		<comments>http://allyourcodearebelongto.me/blog/2008/10/13/context-sensitive-auto-completion-using-powershell-powertab-and-git/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 19:33:46 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[GIT]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2008/10/13/context-sensitive-auto-completion-using-powershell-powertab-and-git/</guid>
		<description><![CDATA[Powertab is an Awesome PowerShell TabExpansion extension. It extends the default PowerShell autocompletion and shows the results like:
 
The best part is that it is easily customizable.
One way to customize it is by editing it Tab Expansion database file which is located in your powershell profile directory:
TabExpansion.xml

To display some simple git commands in autocompletion all [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://thepowershellguy.com/blogs/posh/pages/powertab.aspx">Powertab</a> is an Awesome PowerShell TabExpansion extension. It extends the default PowerShell autocompletion and shows the results like:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image7.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb8.png" width="541" height="488"></a> </p>
<p>The best part is that it is easily customizable.</p>
<p>One way to customize it is by editing it Tab Expansion database file which is located in your powershell profile directory:</p>
<p><strong>TabExpansion.xml</strong></p>
<p><span id="more-113"></span>
<p>To display some simple git commands in autocompletion all the following entries to it:</p>
</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span>git<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span>status<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span>Custom<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span>git<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span>add .<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span>Custom<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  12:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span>git<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  13:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span>pull<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  14:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span>Custom<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  15:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courie
r, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  16:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  17:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span>git<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  18:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span>push<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  19:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span>Custom<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  20:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  21:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  22:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span>git<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  23:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span>commit -m ""<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  24:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span>Custom<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  25:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  26:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  27:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span>git<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Filter</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  28:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span>commit -a -m ""<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Text</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  29:</span>   <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span>Custom<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Type</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  30:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Custom</span><span style="color:#0000ff;">&gt;</span></pre>
</div>
</div>
<p>To invoke this list add the following to <strong>TabExpansion.ps1</strong> file which should be in the source directory:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#006080;">'git(.*)'</span> {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>   <span style="color:#0000ff;">if</span>(Test-Path .git) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>     $<span style="color:#0000ff;">global</span>:dsTabExpansion.Tables[<span style="color:#006080;">'Custom'</span>].select(<span style="color:#006080;">"filter = 'git' AND type = 'Custom'"</span>) | % {$_.text} | Invoke-TabItemSelector  -SelectionHandler $SelectionHandler</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>   }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span> }</pre>
</div>
</div>
<p>This should be added in the Main tabcompletion block inside the switch statement. The function is basically matching the current command name with <strong>git</strong> and then invoking autocompletion.</p>
<p>Now when you type git&lt;tab&gt; then the output should look like below:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image8.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb9.png" width="481" height="303"></a> </p>
<p>I am sure this is not the best way to do custom autocompletion but i couldn’t find an easier way.</p>
<p>This is all static stuff. To add dynamic autocompletion (like providing branch names) add following to the <strong>TabExpansion.ps1 </strong>file:</p>
</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#006080;">'git(.*)'</span> {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>   <span style="color:#0000ff;">if</span>(Test-Path .git) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>     <span style="color:#008000;"># git checkout</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>     <span style="color:#0000ff;">if</span>($lastBlock <span style="color:#cc6633;">-match</span> <span style="color:#006080;">'git checkout'</span>){</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span>       git branch | %{ <span style="color:#0000ff;">if</span>($_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">"^\*?\s*(.*)"</span>){ $matches[1] } } | Invoke-TabItemSelector  -SelectionHandler $SelectionHandler</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>     }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>     <span style="color:#0000ff;">else</span>{</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span>       $<span style="color:#0000ff;">global</span>:dsTabExpansion.Tables[<span style="color:#006080;">'Custom'</span>].select(<span style="color:#006080;">"filter = 'git' AND type = 'Custom'"</span>) | % {$_.text} | Invoke-TabItemSelector  -SelectionHandler $SelectionHandler</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>     }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span>   }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span> }</pre>
</div>
</div>
<p>Now when you type <strong>git checkout &lt;tab&gt;</strong> then it should show the following in the autocomplete list:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image9.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb10.png" width="499" height="220"></a> </p>
<p>This function checks if the user has entered <strong>git checkout</strong> as the command then it runs the <strong>git branch</strong> command, parses it and shows the result as autocomplete list.</p>
<p>Here are couple more commands that I wrote while trying this out:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#006080;">'git(.*)'</span> {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>   <span style="color:#0000ff;">if</span>(Test-Path .git) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>     <span style="color:#008000;"># git checkout</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>     <span style="color:#0000ff;">if</span>($lastBlock <span style="color:#cc6633;">-match</span> <span style="color:#006080;">'git checkout'</span>){</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span>       git branch | %{ <span style="color:#0000ff;">if</span>($_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">"^\*?\s*(.*)"</span>){ $matches[1] } } | Invoke-TabItemSelector  -SelectionHandler $SelectionHandler</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>     }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>     </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span>     <span style="color:#008000;"># git add</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>     Elseif($lastBlock <span style="color:#cc6633;">-match</span> <span style="color:#006080;">'git add'</span>){</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span>       $s = $False ; git status | %{ <span style="color:#0000ff;">if</span>($s <span style="color:#cc6633;">-eq</span> $True -and $_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">"^#\s{1,1}(\S.+)$"</span>){ $matches[1] } ElseIf($_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">'Untracked files:'</span>){ $s = $True } } | Invoke-TabItemSelector  -SelectionHandler $SelectionHandler</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span>     }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  12:</span>     </pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  13:</span>     <span style="color:#008000;"># git rm</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  14:</span>     Elseif($lastBlock <span style="color:#cc6633;">-match</span> <span style="color:#006080;">'git rm'</span>){</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  15:</span>       git status | %{ <span style="color:#0000ff;">if</span>($_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">"^#\s+deleted:\s+(\S.+)$"</span>){ $matches[1] } } | Invoke-TabItemSelector  -SelectionHandler $SelectionHandler</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  16:</span>     }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  17:</span>     </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  18:</span>     <span style="color:#0000ff;">else</span>{</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  19:</span>       $<span style="color:#0000ff;">global</span>:dsTabExpansion.Tables[<span style="color:#006080;">'Custom'</span>].select(<span style="color:#006080;">"filter = 'git' AND type = 'Custom'"</span>) | % {$_.text} | Invoke-TabItemSelector  -SelectionHandler $SelectionHandler</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  20:</span>     }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  21:</span>   }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  22:</span> }</pre>
</div>
</div>
<p>These will autocomplete parameters for <strong>git add</strong> and <strong>git rm </strong>commands by running the <strong>git status </strong>command and parsing the output.</p>
<p>For example:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image10.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb11.png" width="533" height="322"></a> </p>
<p>&nbsp;</p>
<p>I think a lot more interesting stuff can be created using PowerTab and GIT.</p>
<p>&nbsp;</p>
<h2>Update 1:</h2>
<p>Turns out as pointed by MOW that there is a much easier way to add custom expansions instead of editing the <strong>TabExpansion.xml</strong> file. </p>
<p>Just run this command inside PowerShell:</p>
<p>Invoke-TabExpansionEditor</p>
<p>It will open up a dialog box like:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image15.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb16.png" width="338" height="185"></a> </p>
<p>Here custom items can be added by clicking the <strong>Custom</strong> link and then the database change can by saved by running the command:</p>
<p>Export-tabExpansionDataBase</p>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2008/10/13/context-sensitive-auto-completion-using-powershell-powertab-and-git/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Displaying GIT Branch on your PowerShell prompt</title>
		<link>http://allyourcodearebelongto.me/blog/2008/10/12/displaying-git-branch-on-your-powershell-prompt/</link>
		<comments>http://allyourcodearebelongto.me/blog/2008/10/12/displaying-git-branch-on-your-powershell-prompt/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 07:48:28 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[GIT]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2008/10/12/displaying-git-branch-on-your-powershell-prompt/</guid>
		<description><![CDATA[PowerShell is a command line shell like the command prompt (cmd.exe) but with a lot more features. It can be downloaded from here.
One of the features is that you can change the default prompt. Prompt can be changed by overriding the function with name “prompt”.
This function can be declared inside the PowerShell profile file which [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Windows_PowerShell">PowerShell</a> is a command line shell like the command prompt (cmd.exe) but with a lot more features. It can be downloaded from <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx">here</a>.</p>
<p>One of the features is that you can change the default prompt. Prompt can be changed by overriding the function with name “<strong>prompt</strong>”.</p>
<p>This function can be declared inside the PowerShell profile file which has the path:</p>
<p>C:\Users\Gaurav\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1</p>
<p>If the file does not exist then you will need to create this file. Declaring the following function inside the profile file will change the prompt.</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">function</span> prompt {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>   <span style="color:#0000ff;">return</span> <span style="color:#006080;">"prompt&gt; "</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> }</pre>
</div>
</div>
<p>to:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image3.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb3.png" width="495" height="149"></a> </p>
<p><span id="more-104"></span></p>
<p>Now, to display the git branch as a prompt change the function to the following:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">function</span> prompt {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>   $host.ui.rawui.WindowTitle = $(get-location)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span>   </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>   $prompt_string = <span style="color:#006080;">""</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span>   </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>   <span style="color:#0000ff;">if</span>(Test-Path .git) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>     $prompt_string = <span style="color:#006080;">"GIT"</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span>     git branch | <span style="color:#0000ff;">foreach</span> {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>       <span style="color:#0000ff;">if</span> ($_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">"^\*(.*)"</span>){</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span>         $prompt_string += $matches[1] + <span style="color:#006080;">"&gt; "</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span>       }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  12:</span>     }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  13:</span>   }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  14:</span>   <span style="color:#0000ff;">else</span>{</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  15:</span>     $prompt_string = <span style="color:#006080;">"PS&gt; "</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  16:</span>   }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  17:</span>&nbsp; </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  18:</span>   Write-Host ($prompt_string) -nonewline -foregroundcolor yellow</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  19:</span>   <span style="color:#0000ff;">return</span> <span style="color:#006080;">" "</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  20:</span> }</pre>
</div>
</div>
</p>
<p>and the prompt will look like:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image4.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb5.png" width="554" height="245"></a> </p>
</p>
<p>The code basically is checking if current directory is a git project. This can be done by checking if there is a directory with name “<strong>.git</strong>” in the current directory. If yes then it runs the “<strong>git branch</strong>” command and then passes the result through a regular expression to get the current branch.</p>
<p>Here is my full PowerShell prompt function:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> $Global:CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span> $UserType = <span style="color:#006080;">"User"</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> $CurrentUser.Groups | <span style="color:#0000ff;">foreach</span> { <span style="color:#0000ff;">if</span>($_.value <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">"S-1-5-32-544"</span>) {$UserType = <span style="color:#006080;">"Admin"</span>} }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>&nbsp; </pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span> <span style="color:#0000ff;">function</span> prompt {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>   <span style="color:#0000ff;">if</span>($UserType <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">"Admin"</span>) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>     $host.ui.rawui.WindowTitle = <span style="color:#006080;">""</span> + $(get-location) + <span style="color:#006080;">" : Admin"</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span>     $host.UI.RawUI.ForegroundColor = <span style="color:#006080;">"Yellow"</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>   }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span>   <span style="color:#0000ff;">else</span> {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span>     $host.ui.rawui.WindowTitle = $(get-location)</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  12:</span>   }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  13:</span>   </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  14:</span>   Write-Host(<span style="color:#006080;">""</span>)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  15:</span>   </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  16:</span>   $status_string = <span style="color:#006080;">""</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  17:</span>   </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  18:</span>   <span style="color:#0000ff;">if</span>(Test-Path .git) {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  19:</span>     $status_string = <span style="color:#006080;">"GIT"</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  20:</span>     git branch | <span style="color:#0000ff;">foreach</span> {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  21:</span>       <span style="color:#0000ff;">if</span> ($_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">"^\*(.*)"</span>){</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  22:</span>         $status_string += $matches[1]</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  23:</span>       }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  24:</span>     }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  25:</span>     </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  26:</span>     $git_create_count = 0</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-fa
mily:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  27:</span>     $git_update_count = 0</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  28:</span>     $git_delete_count = 0</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  29:</span>     </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  30:</span>     git status | <span style="color:#0000ff;">foreach</span> {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  31:</span>       <span style="color:#0000ff;">if</span>($_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">"modified:"</span>){ </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  32:</span>         $git_update_count += 1</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  33:</span>       }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  34:</span>       <span style="color:#0000ff;">elseif</span>($_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">"deleted:"</span>){ </pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  35:</span>         $git_delete_count += 1</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  36:</span>       }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  37:</span>       <span style="color:#0000ff;">elseif</span>($_ <span style="color:#cc6633;">-match</span> <span style="color:#006080;">"added:"</span>){ </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  38:</span>         $git_create_count += 1</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  39:</span>       }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  40:</span>     }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  41:</span>     $status_string += <span style="color:#006080;">" u:"</span> + $git_update_count + <span style="color:#006080;">" d:"</span> + $git_delete_count + <span style="color:#006080;">"&gt;"</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  42:</span>   }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  43:</span>   <span style="color:#0000ff;">else</span>{</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  44:</span>     $status_string = <span style="color:#006080;">"PS&gt;"</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  45:</span>   }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  46:</span>&nbsp; </pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  47:</span>   Write-Host ($status_string) -nonewline -foregroundcolor yellow</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  48:</span>   <span style="color:#0000ff;">return</span> <span style="color:#006080;">" "</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  49:</span> }</pre>
</div>
</div>
</p>
</p>
<p>This function also displays updated and deleted files in the current git project.</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image5.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb6.png" width="484" height="191"></a> </p>
<h2>&nbsp;</h2>
<h2>Scripts execution in PowerShell is disabled?</h2>
<p>If you just created the profile file then PowerShell may display the following error message when loading this profile we just created:</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image6.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/10/image-thumb7.png" width="554" height="70"></a> </p>
<p>or</p>
<p><font color="#ff0000">File C:\Users\Gaurav\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see &#8220;get-help about_signing&#8221; for more details.<br />At line:1 char:2<br />+ .&nbsp; &lt;&lt;&lt;&lt; &#8216;C:\Users\Gaurav\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1&#8242;</font></p>
<p><font color="#000000">This is because PowerShell does not allow the execution of scripts by default. To fix this open PowerShell in Admin mode and set the execution policy to unrestricted by running the following command:</font></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> Set-ExecutionPolicy Unrestricted</pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2008/10/12/displaying-git-branch-on-your-powershell-prompt/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Compiling and Installing GIT on windows under cygwin</title>
		<link>http://allyourcodearebelongto.me/blog/2008/04/11/compiling-and-installing-git-on-windows-under-cygwin/</link>
		<comments>http://allyourcodearebelongto.me/blog/2008/04/11/compiling-and-installing-git-on-windows-under-cygwin/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 19:56:10 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[FOSS]]></category>
		<category><![CDATA[GIT]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2008/04/11/installing-git-on-windows/</guid>
		<description><![CDATA[Using GIT was one of the requirements of one of the project that I am doing. Here is how I installed GIT on Windows.
So What is GIT?
The supplied documentation of GIT says that:
Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access [...]]]></description>
			<content:encoded><![CDATA[<p>Using GIT was one of the requirements of one of the project that I am doing. Here is how I installed GIT on Windows.</p>
<h5><span style="text-decoration:underline;">So What is GIT?</span></h5>
<p>The supplied documentation of GIT says that:</p>
<blockquote><p>Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.</p></blockquote>
<p><a href="http://en.wikipedia.org/wiki/Git_(software)">Here</a> is the link for the wikipedia entry.</p>
<h5><span style="text-decoration:underline;">Where can I download GIT?</span></h5>
<p><a href="http://git.or.cz/">Here</a> is the link.</p>
<p><span id="more-81"></span>Before following the given steps you will need to install cygwin on your system, and add its bin directory to the system path (so that all the cygwin commands are available from inside the command prompt).</p>
<p>So after installing cygwin run setup.exe inside the cygwin installation folder and make sure the following modules are installed.</p>
<ol>
<li>make</li>
<li>gcc c anc c++ compilers</li>
<li>openssl-devel</li>
<li>curl-devel</li>
<li>Any other dependencies that are missing..</li>
</ol>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/04/image.png"><img style="border-width:0;" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2008/04/image-thumb.png" border="0" alt="image" width="576" height="431" /></a></p>
<p>All these packages are located inside the <strong>Devel</strong> branch of the package tree. Required dependencies will be selected automatically.</p>
<p>Click next to install selected packages.</p>
<h5><span style="text-decoration:underline;">Compiling GIT form source</span></h5>
<p>Untar the GIT source you downloaded using the command <strong>&#8220;tar xvzf git-1.5.5.tar.gz&#8221;</strong> .</p>
<p>Navigate to the untarred directory using a command prompt. Now run the <strong>&#8220;make&#8221;</strong> command inside the GIT source directory.</p>
<p>If it runs successfully then run <strong>&#8220;make install&#8221;.</strong></p>
<p>Before running the command make sure you have <strong>Perl</strong> (language) installed. You can check it by running the command:</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;max-height:200px;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">perl -MCPAN -e 'shell'</pre>
</div>
</div>
<p>and then running the following inside the cpan shell:</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;max-height:200px;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">install blib</pre>
</div>
</div>
<p>it should show no error. I am not sure if this is the best way to do this as I am not much of a Perl guy.</p>
<p>So as I mentioned before you need to run the following two command to make and install Perl:</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;max-height:200px;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> make</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span> make install</pre>
</div>
</div>
<p>If these two steps complete successfully then your GIT is ready to go :). You can test this by running the &#8220;git&#8221; command. This command is located inside the <strong>&#8220;C:/cygwin/home/gaurav/bin&#8221;</strong>. You might to add this folder to the system path too.</p>
<h5><span style="text-decoration:underline;">Pre-configured version</span></h5>
<p><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/FOSS/cygwin_1.5.25-11_git_1.5.5.rar">Here</a> is a cygwin version pre-configured to compile GIT. It is installed on my system and works fine. Cygwin 1.5.25 and GIT 1.5.5 are preinstalled in this archive. Just decompress this archive under folder <strong>&#8220;C:\cygwin&#8221; </strong>and add <strong>&#8220;C:\cygwin\bin&#8221; </strong>and <strong>&#8220;C:/cygwin/home/gaurav/bin&#8221; </strong>to your system path and GIT should work form any command window.</p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1487e1d8-ec5e-4ba8-b3a3-1a759709f417" class="wlWriterSmartContent" style="display:inline;float:none;margin:0;padding:0;">del.icio.us Tags: <a rel="tag" href="http://del.icio.us/popular/GIT">GIT</a>,<a rel="tag" href="http://del.icio.us/popular/open%20source">open source</a>,<a rel="tag" href="http://del.icio.us/popular/perl">perl</a>,<a rel="tag" href="http://del.icio.us/popular/vista">vista</a>,<a rel="tag" href="http://del.icio.us/popular/windows">windows</a>,<a rel="tag" href="http://del.icio.us/popular/cygwin">cygwin</a></div>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2008/04/11/compiling-and-installing-git-on-windows-under-cygwin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>New and Improved Sudo for Vista (now remembers credentials)</title>
		<link>http://allyourcodearebelongto.me/blog/2008/04/02/new-and-improved-sudo-for-vista-now-remembers-credentials/</link>
		<comments>http://allyourcodearebelongto.me/blog/2008/04/02/new-and-improved-sudo-for-vista-now-remembers-credentials/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 11:02:14 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[sudo]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[vista, security]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2008/04/02/new-and-improved-sudo-for-vista-now-remembers-credentials/</guid>
		<description><![CDATA[In one of my earlier blog post I shared source code for a simple utility that I had made. It could be used to launch elevated processes from the command line.
So opening a Elevated command prompt was as simple as writing


sudo cmd


Actually the code for this is very simple as it just executes a well [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my earlier <a href="http://techblogging.wordpress.com/2007/11/28/sudo-for-vista/">blog post</a> I shared source code for a simple utility that I had made. It could be used to launch elevated processes from the command line.</p>
<p>So opening a Elevated command prompt was as simple as writing</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;max-height:200px;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;">sudo cmd</pre>
</div>
</div>
<p>Actually the code for this is very simple as it just executes a well documented system function <a href="http://msdn2.microsoft.com/en-us/library/ms647732.aspx">ShellExecute</a>.</p>
<p>I have made some changes to the script and now it remembers the credentials. So once you execute any command, Vista will ask you confirmation only once and any subsequent call won&#8217;t ask for the confirmation with the UAC dialog box.</p>
<p><span id="more-80"></span></p>
<p>The concept behind this is very simple too:</p>
<p>A process launched from any elevated process will be (by default) automatically elevated at administrative assess. So what this script (client) does is launch a <em>elevated Ruby server </em>first time you run it, so it will Vista will prompt you for confirmation. For any subsequent call it will just see that the server is already running and it will just use that server for elevating launched processes.</p>
<p><u></u>&nbsp;</p>
<h4><u>How it works:</u></h4>
<p>When you write &#8220;sudo cmd&#8221; in the command prompt (or run it any where else):</p>
<ul>
<li>Check if the &#8220;sudo server&#8221; process is running. If not then start it. (This will result in a UAC prompt).
<li>Connect to the server using TCP and ask it to run the command &#8220;sudo cmd&#8221;.
<li>The server will launch the elevated process.</li>
</ul>
<p>&nbsp;</p>
<p>The code for Client and the Server is in Ruby and thus can easily be improved upon. One can easily add code to kill the server after a specific time interval or after running a fixed number of commands. Actually <strong>I am not sure if this is the correct way to handle this</strong>, so any comments will be welcome.</p>
<p>&nbsp;<u><a href="http://cid-49208a72e4eb818c.skydrive.live.com/self.aspx/world/code/sudo.rar">Download Here</a></u></p>
<p>Just un-rar this file anywhere and add it to <a href="http://banagale.com/changing-your-system-path-in-windows-vista.htm">system path</a>. To run it just write sudo &lt;command name&gt; in &#8220;command prompt&#8221; of in the &#8220;Run dialog box&#8221;. Example to run notepad: &#8220;sudo notepad&#8221;</p>
<p>This code was written with ruby 1.8.6.</p>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2008/04/02/new-and-improved-sudo-for-vista-now-remembers-credentials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tabs for windows explorer</title>
		<link>http://allyourcodearebelongto.me/blog/2007/12/01/tabs-for-windows-explorer/</link>
		<comments>http://allyourcodearebelongto.me/blog/2007/12/01/tabs-for-windows-explorer/#comments</comments>
		<pubDate>Sat, 01 Dec 2007 14:31:20 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[XP]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2007/12/01/tabs-for-windows-explorer/</guid>
		<description><![CDATA[QT Tab Bar is a new software that I have come across that alows you to have tabs on windows explorer.
 
It integrates very well in the windows interface and adds features that are normally associated to a web browser like firefox. When you middle click on a folder it opens in a new tab, [...]]]></description>
			<content:encoded><![CDATA[<p>QT Tab Bar is a new software that I have come across that alows you to have tabs on windows explorer.</p>
<p><a href="http://allyourcodearebelongto.me/blog/wp-content/uploads/2007/12/untitled.jpg"><img style="border-width:0;" height="487" alt="Untitled" src="http://allyourcodearebelongto.me/blog/wp-content/uploads/2007/12/untitled-thumb.jpg" width="644" border="0"></a> </p>
<p>It integrates very well in the windows interface and adds features that are normally associated to a web browser like firefox. When you middle click on a folder it opens in a new tab, middle click opens a tab and it also stores a history for tabs.</p>
<p>You can optionally make many more changes to the explorer making more usable and easier to navigate.</p>
<p>The download link is on <a href="http://members.at.infoseek.co.jp/Quizo/freeware/indexEn.html">this</a> page.</p>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2007/12/01/tabs-for-windows-explorer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sudo for Vista</title>
		<link>http://allyourcodearebelongto.me/blog/2007/11/28/sudo-for-vista/</link>
		<comments>http://allyourcodearebelongto.me/blog/2007/11/28/sudo-for-vista/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 05:16:40 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[vista]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2007/11/28/sudo-for-vista/</guid>
		<description><![CDATA[The following ruby script when given any executable file path as the argument runs it in administrative mode.


   1: require 'Win32API'
   2:&#160; 
   3: def shell_execute(process_name)
   4:     process = ''
   5:     process.replace(process_name)
   6:   [...]]]></description>
			<content:encoded><![CDATA[<p>The following ruby script when given any executable file path as the argument runs it in administrative mode.</p>
<div>
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> require <span style="color:#008000;">'Win32API'</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>&nbsp; </pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> def shell_execute(process_name)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span>     process = <span style="color:#008000;">''</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span>     process.replace(process_name)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>     se = Win32API.<span style="color:#0000ff;">new</span>(<span style="color:#006080;">"shell32"</span>, <span style="color:#006080;">"ShellExecute"</span>, [<span style="color:#008000;">'P','P','P','P','P','I'], 'I')</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span>     se.<span style="color:#0000ff;">Call</span>(nil,<span style="color:#006080;">"runas"</span>,process,nil,nil,5)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span> <span style="color:#0000ff;">end</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>&nbsp; </pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span> shell_execute(ARGV[0])</pre>
</div>
</div>
<p>&nbsp;</p>
<p>In Vista you can do the same by right clicking on the file and selecting &#8220;Run as Administrator&#8221; but this script allows you to run a process in admin mode using the command line.</p>
<p>The ShellExecute function resides in the shell32.dll and is documented <a href="http://msdn2.microsoft.com/en-us/library/ms647732.aspx">here</a>.</p>
<p>By just giving &#8220;runas&#8221; as the second parameter to the function the process is executed in the administrative mode.</p>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2007/11/28/sudo-for-vista/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Periodically changing desktop wallpaper using Ruby</title>
		<link>http://allyourcodearebelongto.me/blog/2007/11/27/changing-desktop-wallpaper-using-ruby/</link>
		<comments>http://allyourcodearebelongto.me/blog/2007/11/27/changing-desktop-wallpaper-using-ruby/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 16:46:15 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[XP]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2007/11/27/changing-desktop-wallpaper-using-ruby/</guid>
		<description><![CDATA[Here is small ruby script that picks up a random image from a given folder and sets it as the desktop wallpaper.


   1: require 'Win32API'
   2:&#160; 
   3: SPI_SETDESKWALLPAPER = 20
   4: SPIF_SENDCHANGE = 0x2
   5: SOURCE_FOLDER = "C:\\Users\\Gaurav\\Pictures\\Best\\"
   6:&#160; 
   [...]]]></description>
			<content:encoded><![CDATA[<p>Here is small ruby script that picks up a random image from a given folder and sets it as the desktop wallpaper.</p>
<div style="border-right:gray 1px solid;border-top:gray 1px solid;font-size:8pt;overflow:auto;border-left:gray 1px solid;width:97.5%;cursor:text;max-height:200px;line-height:12pt;border-bottom:gray 1px solid;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;margin:20px 0 10px;padding:4px;">
<div style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;padding:0;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   1:</span> require <span style="color:#008000;">'Win32API'</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   2:</span>&nbsp; </pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   3:</span> SPI_SETDESKWALLPAPER = 20</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   4:</span> SPIF_SENDCHANGE = 0x2</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   5:</span> SOURCE_FOLDER = <span style="color:#006080;">"C:\\Users\\Gaurav\\Pictures\\Best\\"</span></pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   6:</span>&nbsp; </pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   7:</span> files = Dir.entries(SOURCE_FOLDER) - [<span style="color:#006080;">"."</span>, <span style="color:#006080;">".."</span>]</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   8:</span> file = files[rand(files.length)]</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">   9:</span>&nbsp; </pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:#f4f4f4;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  10:</span> systemParametersInfo = Win32API.<span style="color:#0000ff;">new</span>(<span style="color:#006080;">"user32"</span>,<span style="color:#006080;">"SystemParametersInfo"</span>,[<span style="color:#006080;">"I"</span>, <span style="color:#006080;">"I"</span>, <span style="color:#006080;">"P"</span>, <span style="color:#006080;">"I"</span>],<span style="color:#006080;">"I"</span>)</pre>
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, 'Courier New', courier, monospace;background-color:white;border-style:none;margin:0;padding:0;"><span style="color:#606060;">  11:</span> p systemParametersInfo.<span style="color:#0000ff;">call</span>(SPI_SETDESKWALLPAPER, 1, SOURCE_FOLDER + file, SPIF_SENDCHANGE)</pre>
</div>
</div>
<div>&nbsp;</div>
<p>The constant SOURCE_FOLDER can be changed to point at the folder which contain all your wallpaper and the script then randomly chooses a wallpaper from the collection.</p>
<p>You can also set your task scheduler to run this script automatically after a fixed interval so that your desktop wallpaper keeps changing.</p>
<p>Here is the <a href="http://pastie.caboo.se/182290">pastie</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2007/11/27/changing-desktop-wallpaper-using-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Windows XP SP3 boasts speed boost, testers claim</title>
		<link>http://allyourcodearebelongto.me/blog/2007/11/27/windows-xp-sp3-boasts-speed-boost-testers-claim/</link>
		<comments>http://allyourcodearebelongto.me/blog/2007/11/27/windows-xp-sp3-boasts-speed-boost-testers-claim/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 04:45:32 +0000</pubDate>
		<dc:creator>Gaurav</dc:creator>
				<category><![CDATA[XP]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[vista]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://techblogging.wordpress.com/2007/11/27/windows-xp-sp3-boasts-speed-boost-testers-claim/</guid>
		<description><![CDATA[According to this link http://www.computerworld.com/action/article.do?command=printArticleBasic&#38;articleId=9048658 SP3 has made XP significantly faster.
Like users needed another reason for not migrating to VISTA.
]]></description>
			<content:encoded><![CDATA[<p>According to this link <a href="http://www.computerworld.com/action/article.do?command=printArticleBasic&amp;articleId=9048658">http://www.computerworld.com/action/article.do?command=printArticleBasic&amp;articleId=9048658</a> SP3 has made XP significantly faster.</p>
<p>Like users needed another reason for not migrating to VISTA.</p>
]]></content:encoded>
			<wfw:commentRss>http://allyourcodearebelongto.me/blog/2007/11/27/windows-xp-sp3-boasts-speed-boost-testers-claim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
