Skip to content

Instantly share code, notes, and snippets.

@ddpruitt
Last active August 1, 2022 13:00
Show Gist options
  • Save ddpruitt/a3f08aba100fa78fe548682952745ccf to your computer and use it in GitHub Desktop.
Save ddpruitt/a3f08aba100fa78fe548682952745ccf to your computer and use it in GitHub Desktop.

Creating a Pretty Prompt in Windows Termainal


posh-git

posh-git is a PowerShell module that integrates Git and PowerShell by providing Git status summary information that can be displayed in the PowerShell prompt.

posh-git also provides tab completion support for common git commands, branch names, paths and more. For example, with posh-git, PowerShell can tab complete git commands like checkout by typing git ch and pressing the tab key. That will tab complete to git checkout and if you keep pressing tab, it will cycle through other command matches such as cherry and cherry-pick. You can also tab complete remote names and branch names e.g.: git pull or<tab> ma<tab> tab completes to git pull origin main.

oh-my-posh

Oh My Posh is a custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable.

Terminal-Icons

A PowerShell module to show file and folder icons in the terminal.

Terminal-Icons is a PowerShell module that adds file and folder icons when displaying items in the terminal. This relies on the custom fonts provided by Nerd Fonts.

You must be using one of the fonts provided by Nerd Fonts for this module to work as these fonts include tons of custom glyphs/icons that are referenced by their unicode number.

Install and Configure

winget install oh-my-posh

Install-Module posh-git -Scope CurrentUser
Install-Module -Name Terminal-Icons -Repository PSGallery -Scope CurrentUser

Edit the $PROFILE file (~\Documents\Powershell\Microsoft.PowerShell_profile.ps1), add the following lines to the top:

Import-Module posh-git
Import-Module -Name Terminal-Icons

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\blue-owl.omp.json" | Invoke-Expression

More oh-my-posh prompts can be found at Themes | Oh My Posh.

Windows Terminal Settings

Change the Windows Terminal profile settings for Powershell Core to:

    {
        "antialiasingMode": "cleartype",
        "colorScheme": "Campbell",
        "font":
        {
            "face": "CaskaydiaCove NF"
        },
        "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
        "hidden": false,
        "name": "PowerShell",
        "source": "Windows.Terminal.PowershellCore"
    }

Notes:

  • The guid could be different.
  • The font face is important for the correct icons.

Terminal Window

Visual Studio Code Terminal

Be sure to change the Font setting for the VS Code terminal or the icons will not show properly.

VSCode Terminal Font Setting


References

PowerShell Modules

Written guides:

Fonts and Themes

@ddpruitt
Copy link
Author

ddpruitt commented Aug 1, 2022

terminal_window

@ddpruitt
Copy link
Author

ddpruitt commented Aug 1, 2022

vscode_terminal_font_setting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment