Windows terminal beautification and PowerShell beautification through OhMyPosh

Customize PowerShell through Powerline to provide Git status prompt, beautify Windows Terminal, and get an excellent terminal experience

Here is Microsoft's official tutorial:

https://docs.microsoft.com/zh-cn/windows/terminal/tutorials/powerline-setup#set-up-powerline-in-wsl-ubuntu

However, the documents given by Microsoft are flawed. At the time of writing this article, the documents have not been modified. You might as well follow my steps to set them

Install fonts for OhMyPosh

If the font is not installed, the terminal may be garbled in the end

Here, we need to install the Meslo LGM NF font, which is officially recommended by Oh my Posh. When using the Cascadia Code PL and Cascadia Mono PL recommended by Microsoft, the icon will not be displayed

Github link:

https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip

Bad network can be downloaded through Github's mirror station

https://hub.fastgit.org/ryanoasis/nerd-fonts/releases/download/v2.1.0/Meslo.zip

After downloading, unzip it, enter the ttf folder, select the ttf files in the following figure, which are regular, bold, italic and bold italic respectively, and right-click to install

After installation, you can preview in font settings

Installing posh GIT and oh my posh in PowerShell

Before performing this step, make sure you have git installed

In this step, we will install posh GIT and oh my posh:

In the PoweShell window, open PowerShell with Terminal, and execute the following command

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

If you want to install for all users, use the administrator to open Terminal or PowerShell and execute the following command

Install-Module posh-git
Install-Module oh-my-posh

If an untrusted repository appears, select A

If you need to update both tools, execute the following command

Update-Module -Name posh-git
Update-Module -Name oh-my-posh

Note that globally installed modules require administrator privileges to be updated

After the update, we need to uninstall the old version of the module

Get the version number of the module first. You need to remember the version number of the old version

Get-Module -ListAvailable

Uninstalling older versions of modules

Uninstall-Module -Name "posh-git" -RequiredVersion "0.7.3"
Uninstall-Module -Name "oh-my-posh" -RequiredVersion "3.106.7"

Finally, confirm whether the uninstall is successful

Customize PowerShell prompt

Now import posh GIT and oh my posh into the current PowerShell window

Import-Module posh-git
Import-Module oh-my-posh

Then we enter the following command to preview the effect

Get-PoshThemes

Choose the theme you like and remember its name. I choose honukai theme here

Enter this command

notepad $PROFILE

Add the following content to execute the commands in PowerShell every time you open it

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme honukai

Save and exit, reopen PowerShell, and you will see the theme you selected

This is different from Microsoft's official documents, because the new version of oh my posh is rewritten with go, and the instruction has changed, so the old command is invalid

Windows terminal beautification

Open Terminal, click Ctrl + to open the configuration file

My configuration file is released here. You can also set it yourself, but the "fontFace" must be set to MesloLGM NF font, otherwise it will be garbled

"fontFace": "MesloLGM NF",

Profile:

// This file was initially generated by Windows Terminal 1.0.1401.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
  "$schema": "https://aka.ms/terminal-profiles-schema",

  "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

  // You can add more global application settings here.
  // To learn more about global settings, visit https://aka.ms/terminal-global-settings

  // If enabled, selections are automatically copied to your clipboard.
  "copyOnSelect": false,

  // If enabled, formatted data is also copied to your clipboard
  "copyFormatting": false,

  // A profile specifies a command to execute paired with information about how it should look and feel.
  // Each one of them will appear in the 'New Tab' dropdown,
  //   and can be invoked from the commandline with `wt.exe -p xxx`
  // To learn more about profiles, visit https://aka.ms/terminal-profile-settings
  "profiles": {
    "defaults": {
      // Put settings here that you want to apply to all profiles.
    },
    "list": [
      {
        // Make changes here to the powershell.exe profile.
        "backgroundImage": "E://WIP-6th-anniversary-wallpaper-dark.jpg",
        "backgroundImageOpacity": 0.6,
        "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "name": "Windows PowerShell",
        "commandline": "powershell.exe",
        "colorScheme": "AdventureTime",
        "useAcrylic": false,
        "closeOnExit": true,
        "acrylicOpacity": 0.25,
        "cursorColor": "#FFFFFF",
        "fontFace": "MesloLGM NF",
        "tabTitle": "Powershell",
        "hidden": false
      },
      {
        // Make changes here to the cmd.exe profile.
        "backgroundImage": "E://WIP-6th-anniversary-wallpaper-dark.jpg",
        "backgroundImageOpacity": 0.6,
        "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
        "name": "command prompt",
        "commandline": "cmd.exe",
        "colorScheme": "AdventureTime",
        "useAcrylic": false,
        "closeOnExit": true,
        "acrylicOpacity": 0.25,
        "cursorColor": "#FFFFFF",
        "fontFace": "MesloLGM NF",
        "hidden": false
      },
      {
        "backgroundImage": "E://WIP-6th-anniversary-wallpaper-dark.jpg",
        "backgroundImageOpacity": 0.6,
        "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
        "hidden": false,
        "name": "Ubuntu-20.04",
        "source": "Windows.Terminal.Wsl",
        "startingDirectory": "//wsl$/Ubuntu-20.04/home/hominsu",
        "colorScheme": "AdventureTime",
        "useAcrylic": false,
        "closeOnExit": true,
        "acrylicOpacity": 0.25,
        "cursorColor": "#FFFFFF",
        "fontFace": "MesloLGM NF"
      },
      {
        "backgroundImage": "E://WIP-6th-anniversary-wallpaper-dark.jpg",
        "backgroundImageOpacity": 0.6,
        "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
        "hidden": false,
        "name": "Ubuntu-18.04",
        "source": "Windows.Terminal.Wsl",
        "startingDirectory": "//wsl$/Ubuntu-18.04/home/hominsu",
        "colorScheme": "AdventureTime",
        "useAcrylic": false,
        "closeOnExit": true,
        "acrylicOpacity": 0.25,
        "cursorColor": "#FFFFFF",
        "fontFace": "MesloLGM NF"
      },
      {
        "backgroundImage": "E://WIP-6th-anniversary-wallpaper-dark.jpg",
        "backgroundImageOpacity": 0.6,
        "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
        "colorScheme": "AdventureTime",
        "useAcrylic": false,
        "closeOnExit": true,
        "acrylicOpacity": 0.25,
        "cursorColor": "#FFFFFF",
        "fontFace": "MesloLGM NF",
        "hidden": false,
        "name": "Azure Cloud Shell",
        "source": "Windows.Terminal.Azure"
      }
    ]
  },

  // Add custom color schemes to this array.
  // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
  "schemes": [
    {
      "name": "AdventureTime",
      "black": "#050404",
      "red": "#bd0013",
      "green": "#4ab118",
      "yellow": "#e7741e",
      "blue": "#0f4ac6",
      "purple": "#665993",
      "cyan": "#70a598",
      "white": "#f8dcc0",
      "brightBlack": "#4e7cbf",
      "brightRed": "#fc5f5a",
      "brightGreen": "#9eff6e",
      "brightYellow": "#efc11a",
      "brightBlue": "#1997c6",
      "brightPurple": "#9b5953",
      "brightCyan": "#c8faf4",
      "brightWhite": "#f6f5fb",
      "background": "#000000",
      "foreground": "#f8dcc0"
    }
  ],

  // Add custom keybindings to this array.
  // To unbind a key combination from your defaults.json, set the command to "unbound".
  // To learn more about keybindings, visit https://aka.ms/terminal-keybindings
  "keybindings": [
    // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
    // These two lines additionally bind them to Ctrl+C and Ctrl+V.
    // To learn more about selection, visit https://aka.ms/terminal-selection
    {
      "command": {
        "action": "copy",
        "singleLine": false
      },
      "keys": "ctrl+c"
    },
    {
      "command": "paste",
      "keys": "ctrl+v"
    },

    // Press Ctrl+Shift+F to open the search box
    {
      "command": "find",
      "keys": "ctrl+shift+f"
    },

    // Press Alt+Shift+D to open a new pane.
    // - "split": "auto" makes this pane open in the direction that provides the most surface area.
    // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
    // To learn more about panes, visit https://aka.ms/terminal-panes
    {
      "command": {
        "action": "splitPane",
        "split": "auto",
        "splitMode": "duplicate"
      },
      "keys": "alt+shift+d"
    }
  ]
}

This is the picture in the file. This picture was thrown into my mailbox by Microsoft one day. It's very nice and has been used for a long time

Put a link here

https://image.hauhau.cn/WIP-6th-anniversary-wallpaper-dark.jpg

https://image.hauhau.cn/WIP-6th-anniversary-wallpaper-light.jpg

So far, our beautification has been basically completed

Added by GoodCoffee on Wed, 12 Jan 2022 04:19:05 +0200