“This is the 9th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”
Optimize your Windows Terminal with Windows Terminal
windows Terminal
Windows Terminal is a new command line program released by Microsoft in 2019, Is a set of Windows operating system on the original CMD, Powershell, Windows Subsystem for Linux (WSL) on a more beautiful interface, more powerful terminal tool
Windows Terminal advantage
- modern
Can be DIY
Interface, abandon static terminal style - Full font rendering mechanism (Emoji, Chinese)
- Unified Fluent design style with Windows
- GPU acceleration
- Support PowerShell, CMD, and Windows Linux Subsystem (WSL)
- The default Tab mode eliminates the need to create multiple terminals
Of course I only use this because I want a better looking terminal
Installation method
- Users can search for Windows Terminal installation in the Microsoft App Store by themselves, but I have to note that sometimes in China, it is really lucky to enter a Microsoft account or download things in the app store. Anyway, I have been waiting for a long time to come down here
- Download the appropriate version installation on Github, linked here
PowerShell Core
Microsoft has released PowerShell Core, a new version of PowerShell. The new version of PowerShell is available on all major computing platforms, including Windows, Linux and MacOS. Win10 usually comes with PowerShell5
The first and most important difference is that PowerShell Core is cross-platform and runs on Windows, Linux, and MacOS, whereas older versions only run on Windows. PowerShell Core will provide new feature updates and fixes, while older Powershells will only provide bug fixes and security updates
Installation method
Download link to select MSI file installation
oh-my-posh
Oh-my-posh is a bit like Ubuntu’s Oh-my-zsh, with lots of themes
Install some modules of oh-my-Posh
# PSReadline
Install-Module -Name PSReadLine -AllowPrerelease -Force
# posh-git
Install-Module posh-git -Scope CurrentUser
# oh-my-posh
Install-Module oh-my-posh -Scope CurrentUser
Copy the code
The first two install commands should be fine, oh-my-posh probably won’t download successfully
Command line download oh-my-posh unsuccessful solution
-
Install-Module oh-my-posh – force-verbose Install-Module oh-my-posh – force-verbose
-
Then look at the output below to find the actual url for the oh-my-Posh to install, such as the version 6.2.0 I’m currently installing: https://www.powershellgallery.com/api/v2/package/oh-my-posh/6.2.0, (the link may change, because the link is pointing to the latest version)
-
Download the file in.nupkg format, change the suffix to.zip, and unzip it
-
For example, if I’m going to install Oh-my-posh for Powershell Core, the actual installation path for Powershell is this: C: ProgramFiles\PowerShell\7, the decompressed folder is placed as: C: ProgramFiles\PowerShell\7\Modules\oh-my-posh\6.2.0, and oh-my-posh is installed successfully
Oh-my-posh sets the theme
Install-Module -Name PSReadLine -AllowPrerelease -Force
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme M365Princess
Copy the code
If you only type these commands on the current terminal and do not record them in the configuration file, you will need to type them again the next time you open the terminal to use them. Also set-poshprompt -Theme M365Princess is the new oh-my-posh command to Set the Theme, previously set-theme M365Princess (M365Princess is the Theme name). Use the get-poshthemes command to view all the themes displayed in the current version.
Add or open the PowerShell Core configuration file
Open the configuration file Notepad $PROFILE with Notepad
Add the following to it
Install-Module -Name PSReadLine -AllowPrerelease -Force
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme M365Princess
Copy the code
Font Settings
Note that the Oh-my-Posh theme uses some characters that are not supported by non-Powerline fonts, so if you use the default uniform width font (such as Consolas), you will see garbled characters and incomplete characters in the display
We need to download the right font and set it up,Link in theCousine Nerd Font and DejaVuSansMono Nerd Font are both normal. Set Powershell Core as the default terminal (note that the oh-my-Posh series of installation configurations are all on Powershell Core), open a JSON file, configure the font as shown, and the theme will not be garbled
VScode related Settings
Your VISUAL studio code will change to Cousine Code as you go through the above operations, but you will also have trouble displaying your theme without setting the Font. Not the entire font of VScode), so that the theme will also display perfectly on the VScode terminal