VI Toolkit (for Windows) 1.5 and the PowerShell prompt

One of the first things that I noticed after launching my VI Toolkit (for Windows) 1.5 is the new prompt.  It’s tricked-out with color now, but unfortunately steps on the existing two-row PowerShell prompt I had configured on my system — which was working fine with VITK 1.0.

I tend to use a two-row prompt in all of my shells (cmd.exe, Bash, PowerShell) because long commands get confusing when they wrap to another line. Some people think this is a terrible idea — if you are one of them, feel free to stop reading right now.

Here is the default VITK 1.5 console, along with a typical command:

Command wrapping onto another line.

You can see the customization added by VITK 1.5. Note that VITK 1.0 did not specify a prompt at all — it simply used whatever PowerShell was configured to use. The PowerShell prompt can be configured in a variety of ways, one of which is to create the file: …\My Documents\WindowsPowerShell\profile.ps1 containing:

function global:prompt {(get-location).path + "`n>;"}

That stopped working because VITK 1.5 now specifically defines a prompt function in C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts\Initialize-VIToolkitEnvironment.ps1

To get a two-row prompt, simply open that file and add `n (that symbol is a backtick — above the Tab key on most keyboards) right before the > on line 81 (the last line shown in the snippet below):

# change prompt text
Write-Host "[" -NoNewLine
Write-Host "VI Toolkit" -NoNewLine -foregroundcolor Green
Write-Host "] " -NoNewLine
Write-Host ((Get-location).Path + "`n>") -NoNewLine

You will end up with this:

Two-row prompt with long command.

I don’t think this change causes any harm to the VITK installation — please correct me if I’m wrong.

In related news…
A quick way to set up the standard Windows Command Prompt with two rows is to just load this .reg file:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
(Visited 625 times, 1 visits today)
This entry was posted in Virtualizationism and tagged , , . Bookmark the permalink.