Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Terminal - PowerShell customization via oh-my-posh/posh-git Set-Theme error?

Windows Terminal - PowerShell customization via oh-my-posh/posh-git Set-Theme error?

I follow the exact tutorial of Microsoft link: enter link description here, video link: enter link description here

I have installed Posh-Git and Oh-My-Posh: via this code -

Install-Module posh-git -Scope CurrentUser

Install-Module oh-my-posh -Scope CurrentUser

I have installed PSReadLine: via this code -

Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

I am also created Microsoft.PowerShell_profile.ps1 file by typing- code $PROFILE, in my PowerShell profile and copy/paste this code:

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

But I get this error: enter image description here

like image 438
Nihal Towfiq Avatar asked Feb 21 '21 14:02

Nihal Towfiq


2 Answers

Set-Theme is an oh-my-posh V2 cmdlet; you're likely running V3. Provided you followed the rest of the setup correctly, you can simply replace Set-Theme Paradox with Set-PoshPrompt -Theme Paradox.

More info here: https://ohmyposh.dev/docs/upgrading

like image 180
CoolBots Avatar answered Nov 19 '22 06:11

CoolBots


Try this:

  1. First, ensure that you are using an administrative shell and install with powershell.exe (or Windows Terminal)

  2. Install Powershell Get. Powershell Get MS

The PowerShell Gallery is the central repository for PowerShell content. In it, you can find useful PowerShell modules containing PowerShell commands and Desired State Configuration (DSC) resources.

Install-Module -Name PowerShellGet -Force
  1. Install PS Readline PS Readline GitHub

This module replaces the command line editing experience of PowerShell for versions 3 and up. It provides: Syntax coloring; Simple syntax error and more (watch link upside)

Install-Module PSReadLine
  1. Now, changes your executions policies to Bypass. Read more Here

An execution policy is part of the PowerShell security strategy. Execution policies determine whether you can load configuration files, such as your PowerShell

Set-ExecutionPolicy Bypass

3.1 Check your execution policy:

Get-ExecutionPolicy
  1. Finally, try or reinstall your oh-my-posh. Link oh-my-posh here
Install-Module oh-my-posh -Scope AllUsers

and before replace your existing prompt

Edit $PROFILE in your preferred PowerShell version and add the following line. Autocompletion is available so it will loop through all available themes.

4.1 if you have VSCode

Code $PROFILE

4.2 and write

Set-PoshPrompt -Theme 'posh-theme-here'
like image 44
José Velaides Avatar answered Nov 19 '22 05:11

José Velaides