So, I’ve been practically invisible for a few weeks here, and liable to be invisible for at least one more week … this is my vacation time, so it’s hard to motivate myself to blog about anything. However, I have been spending some time working on a side project: a PowerShell Host.
Now, there are a few other hosts out there, but with PowerShell Analyzer seemingly swallowing up PowerShell IDE and going the fifty dollar route … as an open sourcer and contributor to the PowerShell Community Extensions it seemed to me that this couldn’t be that hard, so I started looking for an open source implementation of PSHostRawUserInterface and couldn’t find one. I mean, there are a couple of implementations out there, but essentially they are the PowerShell Remoting interface (which actually runs inside PowerShell.exe, and thus doesn’t seem to implement anything itself) and a half-implemented console block from a Japanese file manager called kuon …
So, being myself, I stepped in an implemented it in the weirdest way I could think of: on top of a WPF RichTextBox. Yep, that’s right. I’ve made myself a ConsoleTextBox which subclasses the RichTextBox and handles keyboard input etc to behave … roughly … the way a Console should.
It’s far from finished, but it is working, so this is by way of announcing the first public alpha release of PoshConsole! The vast majority of PowerShell scripts will run without a hitch — the only time you’ll have problems is with secure string input (eg: passwords), with direct raw buffer interaction, and with running “legacy” console applications — it does not yet redirect standard input/output/error.
One small tip: if you have the PowerShell Community Extensions installed, you’ll want to remove the alias they set up to pipe help through “less” ... because less is a legacy console app — you won’t get any help at all.
Technorati Tags: PowerShell, Scripting, Windows, Command Line
Jaykul-
Love the console. I posted a bit of feedback and input here: http://rrelyea.spaces.live.com/blog/cns!167AD7A5AB58D5FE!2190.entry
Thanks, Rob
Rob Relyea | Program Manager, WPF & Xaml Language Team
robrelyea.com | /blog | /wpf | /xaml
Rob said:
I couldn’t agree more about the typing performance. I’ve actually captured that as an issue for the next release, I think I need to do some profiling around the event handling on the ConsoleTextBox control. Originally there was some code for syntax highlighting in there which I borrowed from somewhere … I’ve stripped it all out now, but it was actually rescanning the entire document on each “text changed” event!
I sort of intend to get syntax highlighting working on the command-line eventually — and even enable a multi-line friendly mode which requires CTRL+ENTER to send the command, so it’s easier to edit snippets like the prompt function — ideally, something like
$cmd = cat function:\promptorOut-PoshEditing function:\promptwould put the existing function into the next command-line so you could edit it on the fly!Hi Jaykul !
Very very nice job with your console ! I’m a big fan ! I’ve made “advertising” of your console on my blog.
So when I use it with ‘help’, nothing appear at all and I dont have PSCX installed; just :
Name : PowerGadgets
PSVersion : 1.0
Description : Generates Charts, Gauges and Maps Gadgets from Windows PowerShell data
Name : Soapyfrog.Grrr
PSVersion : 1.0
Description : This is a PowerShell snap-in that offers high performance graphics and animation in the co
nsole.
Best regards from France !
Arnaud Petitjean
Well, do you have help aliased to a function or anything? I mean, does the full
Get-Helpwork?