Windows Terminal Personalization Guide

Windows Terminal Personalization Guide

Windows Terminal is a new terminal for your favorite command-line shells, such as Command Prompt, PowerShell, and bash (via Windows Subsystem for Linux (WSL)). Its key features include multiple tabs, panes, Unicode and UTF-8 character support, a GPU-accelerated text rendering engine, and you can also use it to create your own themes and customize text, colors, backgrounds, and shortcuts.

Windows 11 has been shipped with the system, replacing the original CMD command line. Windows 10 can be downloaded from the App Store.

Landscaping Guide

Primary settings - fonts, background images and other settings

Start Windows Terminal, then select the small downward arrow in the title bar - Settings - Select the corresponding terminal (such as PoweShell) - Appearance

Here you can set the color scheme, fonts, background images, etc. Personally I think the default color scheme is average. You can go to the following website to choose.

https://windowsterminalthemes.dev/

Windows Terminal One Half Dark color scheme

打开JSON文件, the settings.json file will be opened in the default text editor, then append the copied code to the end, save it and select it in the terminal color scheme.

I won’t elaborate much here, you can search it yourself on Baidu.

intermediate

This is the focus of this article, beautifying your own terminal.

You'll use Oh My Posh to customize PowerShell or the Windows Subsystem for Linux (WSL) command prompt. Oh My Posh provides theming capabilities for a fully customizable command prompt experience, offering Git status color coding and prompts.

1. Install Oh My Posh

method one:

Download Oh My Posh directly from the App Store

Method Two:

Open the terminal and use winget to download

winget install JanDeDobbeleer.OhMyPosh -s winget

The above is the default method on the official website. We can also specify the Oh My Posh installation location, such as here:

winget install JanDeDobbeleer.OhMyPosh -s winget --location "D:\Program Files\OhMyPosh"

Then the download will start. If the download is very slow, you can try to use the Internet to speed up the download.

Insert image description here

2. Modify PowerShell execution policy

Next, change the Power Shell execution policy and require the administrator to start the terminal.

The execution policy is part of the Windows PowerShell security policy. It determines whether you can load configuration files (including your Windows PowerShell profile file) and run scripts. It will determine which files must be digitally signed before running. )

get-ExecutionPolicy gets the current execution policy of Windows PowerShell

set-ExecutionPolicy modifies user preferences for execution policies in Windows PowerShell

Execution policy status description

  • Restricted means that the status is prohibited, configuration files will not be loaded, and scripts will not be executed. Restricted is the default value.
  • RemoteSigned All scripts downloaded from the Internet must be signed by a trusted publisher (trusted publisher)
  • AllSigned All configuration files and scripts must be signed by a trusted publisher. The script page referred to here includes scripts created on the local computer.
  • Unrestricted loads all configuration files and scripts. If you run a script downloaded from the Internet without a digital signature, you will be prompted whether to execute it before execution.
// 获取 Windows PowerShell 当前执行策略
get-ExecutionPolicy

// 修改 Windows PowerShell 中执行策略
set-ExecutionPolicy RemoteSigned

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-fzryn12B-1666322340602) (Windows Terminal Terminal Personalization Settings Guide.assets/image-20221020190602050.png)]

3. Create a PowerShell configuration file

By default, there should be no such file. We can test it by typing in the terminal

Test-Path $PROFILE
// False 不存在配置文件
// True  存在配置文件

Next, we create this file, whether the terminal has administrator rights or not

New-Item -Path $PROFILE -Type File -Force

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-04bKuoDQ-1666322340603) (Windows Terminal Terminal Personalization Settings Guide.assets/image-20221020191224339-16662643770581.png)]

Then, initialize again, this is to load the default

oh-my-posh init pwsh | Invoke-Expression

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-eSzxvFQX-1666322340604) (Windows Terminal Terminal Personalization Settings Guide.assets/image-20221020191342300.png)]

I recommend the second method, open this ps configuration file and add it to the end of the PowerShell configuration file to set paradoxthe theme. ( paradoxReplace with the theme of your choice.)

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\paradox.omp.json" | Invoke-Expression

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-ND3AUbFo-1666322340605) (Windows Terminal Terminal Personalization Settings Guide.assets/image-20221020193024998.png)]

Now I see how the terminal has sent the change, but it is garbled.

4.Install fonts

When the installation is complete, restart the terminal to see the effect. If your font does not contain the corresponding glyphs, you may see several Unicode replacement characters "▯" throughout the prompt. To see all glyphs in the terminal, it is recommended to install Nerd Font .

You can also preview the font style and select your favorite font package to download and install.

https://www.programmingfonts.org/#agave

Of course, I recommend using the following command to install fonts, which is more worry-free (a terminal with administrator rights is required)

oh-my-posh font install

If you don’t know which font to choose, try the official recommended Meslo LGM NFfonts .

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-nZso7UKk-1666322340605) (Windows Terminal Terminal Personalization Settings Guide.assets/image-20221020191816390.png)]

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-MvDRNQMR-1666322340606) (Windows Terminal Terminal Personalization Settings Guide.assets/image-20221020192333345.png)]

After installing the font, set the corresponding font in the terminal settings and save it. Restart the terminal.

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-jH9v9VfI-1666322340607) (Windows Terminal Terminal Personalization Settings Guide.assets/image-20221020192458053.png)]

The final effect is as follows:

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-gLthh4qk-1666322340607) (Windows Terminal Terminal Personalization Settings Guide.assets/image-20221020192742650.png)]

Tips

There are so many themes that it’s a bit difficult to choose. You can display all the styles directly in the terminal to choose the best one.

get-Poshthemes

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-q3DLoXEe-1666322340608) (Windows Terminal Terminal Personalization Settings Guide.assets/image-20221021095641553.png)]

Then directly replace the theme name in the ps configuration file.

If you don’t know where the ps configuration file is, you can enter the following command to directly open the configuration file

notepad $PROFILE

Display oh-my-posh.exe installation path

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

]

Then directly replace the theme name in the ps configuration file.

If you don’t know where the ps configuration file is, you can enter the following command to directly open the configuration file

notepad $PROFILE

Display oh-my-posh.exe installation path

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

https://ohmyposh.dev/docs/installation/windows
https://learn.microsoft.com/zh-cn/windows/terminal/tutorials/custom-prompt-setup
https://zhuanlan.zhihu.com/p/568837345

Guess you like

Origin blog.csdn.net/no_say_you_know/article/details/127442673