<?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; powershell</title>
	<atom:link href="http://allyourcodearebelongto.me/blog/category/powershell/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>
	</channel>
</rss>
