Living a SharePoint life

Wednesday, March 8, 2023

The Retro Terminal - Looking good in 8-Bit | Part 3

Since my last two articles, PowerShell, as well as the terminal itself, has evolved. It is therefore time to bring Retro PowerShell up to date. Where the first two parts cover Windows PowerShell, this article is an update for PowerShell Core and Windows Terminal and will show you how to let your Terminal look like a Commodore 64.

This post is

I'm assuming that at this point you already have Windows Terminal and PowerShell Core installed and know your way around the configuration accordingly. The first thing we can do is create a new color profile in Terminal that we want to use for Retro PowerShell. The easiest way is to open the JSON configuration of your terminal and add the following color profile to your configuration.

{
    "background": "#352879",
    "black": "#000000",
    "blue": "#352879",
    "brightBlack": "#6C6C6C",
    "brightBlue": "#6C5EB5",
    "brightCyan": "#61D6D6",
    "brightGreen": "#9AD284",
    "brightPurple": "#B4009E",
    "brightRed": "#9A6759",
    "brightWhite": "#959595",
    "brightYellow": "#B8C76F",
    "cursorColor": "#6C5EB5",
    "cyan": "#70A4B2",
    "foreground": "#6C5EB5",
    "green": "#588D43",
    "name": "Commodore64",
    "purple": "#6F3D86",
    "red": "#68372B",
    "selectionBackground": "#70A4B2",
    "white": "#CCCCCC",
    "yellow": "#6F4F25"
}

New shell and new possibilities

If you customize your terminal, you probably already know Oh-my-Posh and use the NerdFonts or like me, use them already. But to make the PowerShell really look like a C64 we need a TrueType font with the CBM character set. In the past I used the font from http://style64.org/release/c64-truetype-v1.0-style. So the problem is to choose between a NerdFont for the functionality and the CBM font for the look.

No compromises

What we need is a C64 font with the extensions from NerdFonts and that's exactly what we can do. To avoid having to customize the font myself, I have a patched version for download here.

I created the PetMe64 NF because I think this font handles special characters and umlauts better. Oh-my-Posh doesn't quite match the look&feel of the C64, but I think this is a good compromise between look and functionality. Add the PetMe64 NF or PetMe64 NF Mono to your operating system and configure your terminal to use the new font.

Final touch

The only thing missing now is the typical startup screen of the C64 after power on. Add the following code section to your Microsoft.PowerShell_profile.ps1 file.

function Set-Mode64 {
    #
    # Make this the last entry, because it clears the shell screen
    # Writing the C64 boot screen to the shell
    #
    #Set-Location C:\
    $Win32OS = Get-WmiObject -Class Win32_OperatingSystem
    $FreeMB = [math]::round(($Win32OS.FreePhysicalMemory /1024), 0)
    $TotalGB = [math]::round(($Win32OS.TotalVisibleMemorySize /1024 /1024),1)
    $osName = $Win32OS.Caption
    $ver = ("V{0}.{1}") -f $Host.Version.Major,$Host.Version.Minor
    $width = $Host.UI.RawUI.WindowSize.Width
 
    $Host.UI.RawUI.WindowTitle = "Power 64 Shell"
    $Host.UI.RawUI.CursorSize = 100
 
    $message1 = "**** $osName POWERSHELL $ver ****"
    $message2 = "$TotalGB GB RAM SYSTEM  $FreeMB POWERSHELL MEGABYTES FREE`r`n`r`n"
    Clear-Host
    $screenXpos = [Math]::Truncate(($width - $message1.Length) / 2)
    [Console]::SetCursorPosition($screenXpos, 1)
    Write-Host $message1
    $screenXpos = [Math]::Truncate(($width - $message2.Length) / 2)
    [Console]::SetCursorPosition($screenXpos, 3)
    Write-Host $message2
    Write-Host "READY."; Write-Host
}
Set-Mode64
Set-Alias -Name Go64 -Value Set-Mode64
Set-Alias -Name cls -Value Set-Mode64

The two lines set-alias are optional. With this you can clear the screen like on the C128 with the go64 command or by using the PowerShell cls command.

That would be all. There are certainly still a few things that can be improved. Just write about it in the comments. I hope these customizations bring you happiness in your daily work with Retro PowerShell.

The Retro Powershell - Looking good in 8-Bit | Part 1
The Retro Powershell - Looking good in 8-Bit | Part 2

Featured Post

How are Microsoft Search quota consumed?

With Office 365 Search, Microsoft has created a central entry point for the modern workplace. In one convenient spot, users can access all ...