Custom console host

Topics: Developer Forum
Jan 9, 2007 at 11:07 PM
I am toying with the idea of writing a custom console host, which would support richer UI.
It wouldnt use the console line-editing api, so for example there wouldnt be a difference between the "arrow up/down history" and powershell get-history. It would enable implementation of a much much richer intellisense experience in the future.
The custom host could also handle more runspaces and display buffers, and provide means to switch between them. The potential less.exe rewrite would be also based on this "console buffer api".
However this all is just a version 3.0 dream :) The separation of infrastructure types I metioned in the previous thread would be the first prerequisite.
Jan 10, 2007 at 1:35 PM
That sounds like a fantastic idea. If there's one down side to PowerShell, it's the fact that by default, it still sits on top of cmd.exe.

One of the biggest strengths that bash has is that it sits on top of readline. The things I miss most are being able to delete entire words with ctrlbackspace, incremental search through the history after ctrlr. It would be great to see these sort of features in a command processor for PowerShell.

OT: By the way, how does one get access to the source code for PSCX?
Jan 10, 2007 at 1:57 PM
yeah, that is exactly what i mean :)

you can download the latest drop on the 'source code' tab on top of the page.
Jan 10, 2007 at 3:57 PM
There are at least two replacement console hosts out there already for powershell, Karl Prosser's PowerShell Analyzer ( ) and one other which escapes me right now. Yes, they have extra whizz-bang gui bits hanging off them too, but essentially they are console hosts.

Some things that would be nice though:

  • ANSI support
  • readline support
  • ncurses support
  • dynamic resizing

- Oisin
Jan 11, 2007 at 4:25 PM
the second one you're talking about is probably which has a TERRIBLE UI and even worse stability (unhandled exceptions almost every time you touch any of its cool ui gadgets)

the power shell analyzer is far better and more mature, but it's essentialy a debugger/editor/ide, not a simple terminal.

  • dynamic resizing: the windows console does not support this, so I am afraid we are out of luck here
  • readline: i do not know readline, i can only imagine what it might support. is there any description of it? speaking of this, i'd like to implement standard "shift-selection" and Ctrl-C, Ctrl-X, Ctrl-V behavior in our readline.
  • ncurses: as i said earlier, there's nothing like win32 ncurses, since win32 console does not support ansi codes. and even if there was a port, i'm afraid it's plain-C wouldnt play well in .net.

so basically, we have to implement everything from scratch. the first step would be to wrap Win32 API in a nice ConsoleScreenBuffer and ConsoleInputBuffer classes. that should be fairy trivial.
next thing would be implementing some WinForms-like message pumping and "window manager" using the console buffer api.
and then finally making a PSHost implementation, which would render itself inside this ConsoleForms window.
Jan 11, 2007 at 5:36 PM
There might be something we can salvage from this:

There's some useful p/invoke code there for reference that we might leverage, e.g. for creating a console "show-popup" cmdlet that displays a popup within the console, rendered in text (old school!) as opposed to a new winform.

- Oisin
Jan 11, 2007 at 6:53 PM
Creating a whole new console host is starting to sound like a little bit more than just some community extensions. :-) Seriously perhaps a new host warrants its own CodePlex project.
Jan 11, 2007 at 11:34 PM
PuTTY is a great console host but the default distribution only runs remote terminals. There is a version out there that has been patched to host local console applications but I can't remember what it is called right now.
Jan 12, 2007 at 1:27 PM
Keith, I'd prefer to develop it here. If it ever leads to something usable and you feel it should not be part of pscx, we can always create a separate project later.

Oisin, thanks for the pointer, there is a lot of useful pinvoke declarations.
Jan 12, 2007 at 9:16 PM
Sounds good.
Jan 13, 2007 at 3:51 PM
I'm not sure you guys have seen this but sourceforge has a console app that will host just about any console application (cmd.exe, bash.exe, powershell.exe, etc). You can find it here
Jan 13, 2007 at 6:04 PM
nope, haven't seen it before -- nice find!

I got it to work with powershell by adding a new <tab> definition in console.xml (using one of the console 2.0 demo zips I downloaded) -

  <tab title="powershell">
    <console shell="c:\windows\system32\windowspowershell\v1.0\powershell.exe" init_dir=""/>
    <cursor style="0" r="255" g="255" b="255"/>
    <background type="2" r="0" g="0" b="0">
      <image file="" relative="0" extend="0" position="0">
        <tint opacity="65" r="0" g="0" b="0"/>

This looks really promising!
Jan 14, 2007 at 1:03 AM
yeah, console2 is a cool project. oisin, you should probably try the latest developer version there, the 2.0 demos are a bit outdated.

however the custom console host is something different. it would use the lowlevel console api, thus it would run in console2 as well. console2 works by starting character-mode applications in a hidden window, polling their output buffer every second or so, and drawing them in the nice, tabbed, transparent UI.
Sep 17, 2007 at 10:01 PM
Edited Sep 17, 2007 at 10:02 PM

jachymko wrote:
yeah, console2 is a cool project. oisin, you should probably try the latest developer version there, the 2.0 demos are a bit outdated.

I tried to find anything newer (or even different) than the 2.0 stuff there - but the only other thing seems to be the older v1.5 stuff. It appears that there is nothing under CVS or SVN - when I try to browse either, I get 0 files... any idea where or how I can get at any newer version(s) that may exist...?

Sep 18, 2007 at 6:57 AM
The build number 132 is pretty recent, I think. You must not look at the date of the "release", since it is the date when the first 2.0 build was released.
Sep 23, 2007 at 1:49 AM
Yeah, they're still developing, and even fixing bugs I filed because of using PowerShell in it. :D
Of course, this thread's a little dated ...

we now have PoshConsole and PowerShell+ in beta ....
Jun 11, 2012 at 6:45 AM
Edited Jun 11, 2012 at 7:15 AM

Sorry for the self-promotion, I'm the author of another Console Emulator, not mentioned here.

Initially, the program was designed to work with Far Manager. But ConEmu can be used with any other console application or simple GUI tools (like PuTTY for example). ConEmu is a live project, open to suggestions.

A brief excerpt from the long list of options:

  *  Use any font installed in the system, or copied to a folder of the program (ttf, otf, fon, bdf)
  *  Run selected tabs as Administrator (Vista+) or as selected user
  *  Windows 7 Jump lists and Progress on taskbar
  *  Integration with DosBox (useful in 64bit systems to run DOS applications)
  *  Smooth resize, maximized and fullscreen window modes
  *  Scrollbar initially hidden, may be revealed by mouseover or checkbox in settings
  *  Optional settings (e.g. pallette) for selected applications
  *  User friendly text and block selection (from keyboard or mouse), copy, paste, text search in console
  *  ANSI X3.64 and Xterm 256 color

Some user reviews: