My Demonstration Prompt

Recently, I have found myself doing a lot of CLI PowerShell demos. Normally, I have a prompt that uses Joel Bennet’s PowerLine module and looks like this.

In my opinion, it’s pretty cool looking, and it gives me a bunch of useful information including the Get-History ID of the line that I ran, the nested prompt level, current drive, the present working directory, the time the last command took to run and whether it was successful, and the current time.

This is way too much information for a regular demo, and ends up in me answering questions about my prompt and explaining it for 5 minutes which eats up valuable demo time. Here’s my new demo prompt.

Not much explaining to do here. Here’s the code I have in my profile to make it happen.

function Invoke-DemoPrompt {
    $demo = 'function prompt {"I $([char]0x1b)[0;31m$([char]9829) $([char]0x1b)[0;0mPS> "} clear-host'
    Invoke-Expression $demo
}

Shout out to Joel and Brandon in the PowerShell Slack for working this one out. It’s pretty simple. $demo is a string that redefines my prompt function and its invoked.

Written on May 3, 2017