Skip to content

A custom PowerShell prompt based on the appearance of oh-my-zsh themes

License

Notifications You must be signed in to change notification settings

OrbitalDan/PSCustomPrompt

Repository files navigation

PSCustomPrompt

I recently discovered the Oh-My-Zsh project, and was inspired by the styles of the themes available for it. Of particular interest was the theme agnoster which uses the powerline project to inject all manner of useful information into the prompt and a rendered statusbar. I decided I wanted to try to replicate some of the slick appearance (if not the functionality) of that within PowerShell!

As luck would have it, one of the missing pieces has just been added in Windows 10 v1511, under the unassuming name of "Console Host Enhancements". Specifically, the windows console can now process ANSI/VT100 terminal control codes, albeit with some limitations. By installing a font patched with the powerline symbols and making it available for use in the console, I was able to produce a similarly nice looking prompt in PowerShell:

Screenshot

It takes a bit of prep work:

  1. Install a powerline patched font. I used DejaVu Sans Mono for Powerline.

  2. Create a REG_SZ subkey in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont". The name should be composed of zeroes (i.e. '000') and the value is the name of the font you installed in step 1, as reported by Character Map.

  3. Re-login or reboot to apply the changes.

  4. Select the font in the properties dialog for the powershell console, and edit the DarkCyan color (fourth box from the left in the color tab) to a nicer shade. I used RGB(0,90,135) to get the result in the screenshot. Note that you have to select DarkCyan before you can edit it, so take note of the color that was selected first, and re-select it after editing. If you ever need the original DarkCyan back, it's RGB(0,128,128).

  5. Uncheck "Legacy Mode" in the command prompt properties.

  6. Import the module with Import-Module PSCustomPrompt.

  7. Customize away! The prompt settings are located in $PSCPSettings. $PSCPSettings.Segments contains several pre-built segments, or you can create your own. The segments in the array $PSCPSetings.Order are rendered into the prompt! See the example in Profile.Example.ps1 for samples.

About

A custom PowerShell prompt based on the appearance of oh-my-zsh themes

Resources

License

Stars

Watchers

Forks

Packages

No packages published