Skip to content

Instantly share code, notes, and snippets.

@bilalix
Last active February 26, 2023 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bilalix/601fb8f967162fa343c0ea969cb9b1a9 to your computer and use it in GitHub Desktop.
Save bilalix/601fb8f967162fa343c0ea969cb9b1a9 to your computer and use it in GitHub Desktop.
How to make a pretty prompt in Windows Terminal

How to make a pretty prompt in Windows Terminal

Screenshot 2021-08-04 234038

This Gist is deprecated, please refer to: https://ohmyposh.dev/docs/installation/windows


Original post: How to make a pretty prompt in Windows Terminal with Powerline, Nerd Fonts, Cascadia Code, WSL, and oh-my-posh (Thanks Scott Hanselman) I copied most of that post content with some modifications, I just want to keep everything uin one place for reference later in the future

I recommend installing Installing PowerShell 7 or above

1. Get the Terminal

Get Windows Terminal free from the Store. You can also get it from GitHub's releases but I recommend the store because it'll stay up to date automatically.

2. Install Posh-Git and Oh-My-Posh (For PowerShell)

Per these directions, install Posh-Git and Oh-My-Posh. This also assumes you've installed Git for Windows.

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

Run these commands from PowerShell or PowerShell 7. I recommend PowerShell 7.1.3 or above. You can also use PowerShell on Linux too, so be aware. When you run Install-Module for the first time you'll get a warning that you're downloading and installing stuff from the internet so follow the prompts appropriately.

Also get PSReadline if you're on PowerShell 7:

Install-Module -Name PSReadLine -RequiredVersion 2.1.0 -Scope CurrentUser

Then run notepad $PROFILE and add these lines to the end:

Windows may prompt asking to create Microsoft.PowerShell_profile.ps1 if it doesn't exist, you can confirm and copy paste the lines below

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme Paradox

After I closed and reopened the terminal I got execution of scripts is disabled on this system. error (Or something like that, I dont remember exactly), to solve it I ran the following command (Source):

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

3. Get a better font

If you do all this and you see squares and goofy symbols, it's likely that the font you're using doesn't have the advanced Powerline glyphs. Those glyphs are the ones that make this prompt look so cool!

Screenshot 2021-08-05 000012

Cascadia Code has been updated with a PL (Powerline) Glyph version! Go get it at https://github.com/microsoft/cascadia-code/releases and in your settings.json under profiles > defaults set the fontFace to "Cascadia Code PL":

"profiles": 
    {
        "defaults": { "fontFace":  "Cascadia Code PL" },
        ...

You can do the same with VSCode. Go to settings, search for terminal font and add 'Cascadia Code PL' to the Font Family (e.g 'Cascadia Code PL', Consolas, 'Courier New', monospace)

Remember also you can get lots of Nerd Fonts at https://www.nerdfonts.com, just make sure you get one (or generate one!) that includes PowerLine Glyphs.

4. Add Autocompletion

PowerShell include PSReadline, you simply need to run notepad $PROFILE and add these line to the end:

Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

As you can see the autocompletion is working as expected:

Screenshot 2021-08-06 145015

Additional resources:

Enjoy!

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