PowerShell posh (oh-my-posh)

PowerShell beautification

1. Add right-click menu

1. Modify the default right-click menu

Directly use this command to change the right-click menu of win11 to the right-click menu of win10:

reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
taskkill /f /im explorer.exe & start explorer.exe

If you want to revert to the win11 default right-click menu:

reg delete "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f
taskkill /f /im explorer.exe & start explorer.exe

2. Find the installation directory

For example, my installation directory:

%LOCALAPPDATA%\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe

3. Modify the registry

Copy this path and open the registry:

win+r->regedit

Enter the path in the registry:

计算机\HKEY_CLASSES_ROOT\Directory\Background\shell

Create a new item:

The name of the entry is:

Open PowerShell Here

Create a new string value:

Change the name to Icon, and change the data to the path we just copied:

At the same time, create a new item inside this item and name itcommand

The default data is modified to the path we just copied

You can also add some startup parameters after this path: you can use pwsh -hto view

Then we can right-click and use:

2. Style modification

1. Environment installation

First, we need to give the current user permission to execute PowerShell scripts:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Then, we use Powershell to run:

Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))

Updated command:

Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))

Necessary font installation: font

Then copy all the fonts inside to C:\Windows\Fontsthe directory and it will be installed automatically.

2. Configuration and use

Use our configured font:

  • Open PowerShell and use shortcut keys Ctrl + Shift + ,to open the configuration file:

Run again:notepad $profile

The first time it will show that the file cannot be found, choose to create a new file, then enter and save

Enter in the file:

oh-my-posh init pwsh | Invoke-Expression

Then go back to the Windows terminal and create a new powershell, and you will see the following content

Modify theme:

$user_name = "steve"
$theme_name = "bubblesextra"
oh-my-posh init pwsh --config "C:\Users\${user_name}\AppData\Local\Programs\oh-my-posh\themes\$theme_name.omp.json" | Invoke-Expression

user_name: is the current username

theme_name: is the current theme name

We can use Get-PoshThemesto view all themes, or we can view all themes through official documents

Finally, we can also modify the background image of the terminal:

My theme beautification results:

Guess you like

Origin blog.csdn.net/qq_62789540/article/details/128739782