PowerTab Powershell Intellisense

Update: I’ve posted an updated version to go along with /\/\o\/\/’s PowerTab 0.9 release, including one important bug fix.

A day or so ago I posted about an implementation of PowerShell “intellisense” I was working on, based on /\/\o\/\/’s really great PowerTab extension for TabExpansion. Well, after a few more hours of work and testing, I think it’s to the point where I can release it to the public and be laughed off the web. :) I think I’ll call it version 0.0.001.

Here are my thoughts on the implementation before you download it and give it a try. Oh, and you can click here to see an animated gif of PowerShell Intellisense in action.

Positive

  • The intellisense window is location-aware. That means it will reposition itself appropriately for screen edges, to ensure it’s visible.
  • It’s easy to select the item you want. You can press tab, press enter, key up/down, or double-click an item, and it interprets keystrokes to auto-select the item you want. It applies the already typed text to the search, so if you had typed [System.Reflection.A[tab] you could continue typing “ssembly” to auto-select [System.Reflection.Assembly].
  • It’s fun, and rather useful! :)

Negative

  • Implementing this felt very “hackish”. I don’t think there’s any other way around it, but still.
  • It’s reliant on TabExpansion, and it is modal (meaning it consumes the focus while it’s open).
  • It’s either Intellisense or nuthin’. I tried to add a global flag variable to turn it on/off, but was unsuccessful (I wasn’t sure how to make the function essentially pass the pipeline input through without modifying it–I appreciate any hints).
  • It displays the entire replacement string instead of just the relevant portions. For example, if I started with this: “[System.Reflection.Assembly]::” I would prefer to see “Load(“, “LoadFile(“, “LoadWithPartialName(“, etc. in the intellisense window instead of “[System.Reflection.Assembly]::Load(“, etc.
  • The entire thing could’ve been done in PowerShell only, but I used a custom assembly because a) I write C# easier than PowerShell, and b) I felt it would be easier to do any (future) fancy custom drawing from within C# than PowerShell.

Here’s what you need to do to install and use it (it’s convoluted, I realize).

  1. Download and install /\/\o\/\/’s PowerTab v0.8 from this link:
    http://thepowershellguy.com/blogs/posh/pages/powertab.aspx
  2. Back up the original TabExpansion.ps1 in the PowerTab subdirectory of your profile directory
  3. Copy the included (new) TabExpansion.ps1 file over the original
  4. Copy Lerch.PowershellIntellisense.dll to your profile directory
  5. Copy Invoke-Intellisense.ps1 to your profile directory
  6. Edit Invoke-Intellisense.ps1 and update the following line to include the full path to the Lerch.PowershellIntellisense.dll file:
    [void][System.Reflection.Assembly]::LoadFile(“Lerch.PowershellIntellisense.dll”) | out-null
  7. Edit your profile and add the following line (add it next to the installed PowerTab lines, for consistency, of course using your appropriate profile directory:
    . ‘C:\Documents and Settings\aaron\My Documents\WindowsPowerShell\Invoke-Intellisense.ps1′ # Load Intellisense function
  8. Close and re-open PowerShell, or just type “. $profile”
  9. Enjoy! (Hopefully!)

Please comment and let me know what you think, and more importantly any improvements I can make — heck, feel free to improve it yourself! I’ll freely offer up the C# source to anybody who wants it. Once it’s a little more refined, I’ll post everything together.

This entry was posted on Tuesday, March 6th, 2007 at 11:30 pm and is filed under powershell. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses to “PowerTab Powershell Intellisense”

  1. aaron Says:

    Pete – yep, /\/\o\/\/ has contacted me with some help, once I find a few minutes (later this week, hopefully – I’m on computerless vacation for a week afterwards) I’ll get it updated.
    Thanks!

  2. Anonymous Says:

    Aaron,
    Can you update to accomodate PowerTab 0.9?
    Pete Gomersall

  3. aaron Says:

    Coming soon… :)

  4. Anonymous Says:

    How about opening the source so we can help you make more progress?

Leave a Reply