Skip to content

Configure powershell with custom prompt and oh-my-posh

Notifications You must be signed in to change notification settings

tahmidul612/pwsh-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

Setup Powershell

Powershell Preview

Install powershell preview with winget

Update app installer from Microsoft store if the install command does not work

winget install --id Microsoft.Powershell.Preview --source winget

Scoop is a package manager for Windows. It installs packages only for the current user (does not need admin privileges) and adds command line alias for the package when needed. The terminal does not have to be restarted to use the alias.

Run these commands in a non-elevated powershell/terminal (regular powershell without admin privileges)

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
iwr -useb get.scoop.sh | iex

Git

Install git (required for some scoop commands)

For a full git setup follow git-config

winget install git.git

Nerd Font

Install FiraCode Nerd Font with scoop

scoop bucket add nerd-fonts
scoop install FiraCode-NF-Mono

Update Default Shell

  • Restart terminal
  • Open terminal settings
  • Change Default profile from Windows Powershell to Powershell

You default profile may be different, change it to Powershell or Powershell Preview

Configure Terminal

  • Open terminal settings
  • Open JSON File
  • Copy and paste this Night Owl Theme into the schemes section
  • Navigate to the Powershell profile
  • Set the Starting Directory
  • Navigate to Powershell > Appearance
  • Set Color Scheme to Night Owl
  • Change Font Face to FiraCode Nerd Font Mono
  • Set Padding to 20 and Scrollbar Visibility to hidden

Set Background opacity to 90% and enable acrylic material (optional)

Open Appearance from the sidebar and turn on Use acrylic material in the tab row (optional)

Install oh-my-posh with winget

winget install JanDeDobbeleer.OhMyPosh -s winget

Restart terminal to enable oh-my-posh command alias

Disable oh-my-posh notices

oh-my-posh disable notice

Install and import PSReadline

Install-Module PSReadLine -AllowPrerelease -Force
Import-Module PSReadLine

Importing PSReadline is required to install psfzf

Install psfzf after installing fzf or the install/import may fail

Install fzf, psfzf, terminal-icons and gsudo

scoop bucket add extras
scoop install fzf terminal-icons
scoop install psfzf
scoop install gsudo

Install ZLocation

Install-Module ZLocation -Scope CurrentUser

Install scoop-search-multisource

For searching scoop directory waaaaay faster than the built in scoop search

scoop install "https://raw.githubusercontent.com/plicit/scoop-search-multisource/master/scoop-search-multisource.json"

Download and copy custom profile to Powershell profile directory

Profile is a modified version of https://thirty25.com/posts/2021/12/optimizing-your-powershell-load-times

iwr -uri "https://github.com/tahmidul612/pwsh-config/raw/master/profile.ps1" -outfile "$PROFILE"

Reload profile to enable the theme and modules

. $PROFILE

Optional Modifications

Gsudo modifications

Enable daily update check

The provided profile has a function to check winget and scoop for updates once every day. This can be enable by uncommenting line 81 in the profile.ps1 file

Update check can be skipped by Ctrl+C, it will not check again that day

Windows Security Exclusion

Check https://ohmyposh.dev/docs/faq#the-prompt-is-slow-delay-in-showing-the-prompt-between-commands for more information

Security scans may be slowing down oh-my-posh, add oh-my-posh executable to Windows Defender exclusion list (or the exclusion list for you antivirus)

OMP Executable location

(Get-Command oh-my-posh).Source

Adding entire the scoop directory, or possibly just the modules directory to the exclusion list may also help

Scoop directory location

echo $env:USERPROFILE\scoop

Path Substitution Fix

Using $env:POSH_THEMES_PATH in the profile.ps1 file may cause a delay in loading the profile. This is a fix for that:

(Get-Content -Path $PROFILE).Replace('$env:POSH_THEMES_PATH', "$($env:POSH_THEMES_PATH)") | Set-Content $PROFILE

Replaces the environment variable with the absolute path

Check devblackops/Terminal-Icons#76 for more information

The terminal-icons module can take a while to load. This is a guide to modify the module to make it load 3x+ faster

About

Configure powershell with custom prompt and oh-my-posh

Topics

Resources

Stars

Watchers

Forks