Post

Style your PowerShell/Terminal with Custom Prompt

Let’s get started

To make a pretty prompt for your terminal (PowerShell/bash/zsh). Get the PowerShell from Windows Store or download the latest version from Github.

Get Windows Terminal

If you are using Windows 11 OS then Windows Terminal (Terminal) will be already installed else Get the Windows Terminal from Microsoft Store or GitHub and set powershell as a default shell. Open settings from Windows Terminal -> Startup and set PowerShell as default shell.

Set-Default-Shell

Nerd Fonts

Customized command prompts often use glyphs (a graphic symbol) in order to style the prompt. If your font does not include the appropriate glyphs, you may see several Unicode replacement characters ‘▯’ throughout your prompt. In order to see all of the glyphs in your terminal, we recommend installing a Nerd Font.

After downloading, you will need to unzip and install the font on your system. See How to add a new font to Windows.

NerdFont

Install 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.

To customize your PowerShell prompt, you can install Oh My Posh using winget. winget installer is an executable installer like apt-get in linux.

1
winget install JanDeDobbeleer.OhMyPosh

Once Oh my Posh is installed then you can customize themes and segments as per your wish.

PowerShell Profile

If you are opening your PowerShell profile for the first time then you can get to know where the profile is located by running $PROFILE in PowerShell terminal.

1
notepad $PROFILE

If there is no default profile present then you can create one under Documents\PowerShell by running above command and save it.

Then edit $PROFILE and add the following line, remembering at this point that oh-my-posh is an executable on the PATH.

1
oh-my-posh --init --shell pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression

Custom Themes/Segments

You can customize the prompts as per wish by modifying the existing json files or creating a one from scratch. Here is my customized version of prompt.

Pretty-Prompt

This post is licensed under CC BY 4.0 by the author.