Strengthen command line in win10

Time:2020-10-26

Strengthen command line in win10

Install Windows terminal

stayMicrosoft StoreDownload fromWindows TerminalPay attention to system requirements

<img style=”zoom:50%;” />

0x2 install PowerShell core

Download address:https://github.com/PowerShell/PowerShell/releases

Win10 selectionPowerShell-7.1.0-preview.7-win-x64.msiThis installation is OK

<img style=”zoom:50%;” />

Installation font (optional)

FiraCode-Hyphen font

<img style=”zoom: 33%;” />

JetBrainsMono-Idea font, personal use of this

0x4 install the PowerShell module

Enter the following command

Through thePowerShellExecute the following command to install as super administratorPowerShell

Right click the blank space on the desktop to selectPowerShell > Open Here as Administrator

CurrentUserYes, install the module only for the current user

! If it appearsPowerShell because scripts are not allowed to run on this system

Enter the following command

#Change execution policy
set-ExecutionPolicy RemoteSigned

#View execution policy
get-ExecutionPolicy
Install-Module posh-git -Scope CurrentUser 
Install-Module oh-my-posh -Scope CurrentUser

If the download is slow, you can use the command line agent

#Set up proxy (fill in your local port)
netsh winhttp set proxy 127.0.0.1:1080
#Cancel agent
netsh winhttp reset proxy
#View agent
netsh winhttp show proxy

0x5 configure PowerShell

0x1 input:

$PROFILE

# C:\Users\SunSeekerX\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

0x2continue input:

if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE

0x3 add in open fileSet-Theme ParadoxYes, set the default theme

This file is the file that starts the execution of PowerShell each time, loads two modules and sets the theme.

Other optional topics are

Agnoster、Avit、Darkblood、Fish、Honukai、Paradox、Sorin、tehrob

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

After saving, close notepad and enter the following command in the terminal to take effect (do not copy here, the value of $profile above is executed below)

C:\Users\SunSeekerX\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

0x5 switch topic

Set theme name

Configure Windows terminal

Detailed configuration of official website

Configure theme colors

0x1 open configuration file setting.json

<img style=”zoom: 50%;” />

0x2 refer to the following configuration

You can modify it by yourself. You must conform to the content format of JSON, or you will report an error. In addition, the path of the image should correspond to your own system

More changes have been madeprofiles > defaultsandschemes, the former is the launched configuration, and the latter is the theme color matching.

Do not copy all the following configuration, you can selectively change your configuration!

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
    "copyOnSelect": false,
    "copyFormatting": false,
    "profiles": {
        "defaults": {
            "Fontface": "JetBrains mono", // oh my posh theme, using other fonts may cause garbled
            // "backgroundImage": "C:\bash- bg.jpg ", // background image address
            //"Backgroundimageopacity": 0.5, // transparency
            "Colorscheme": "Ayu", // color scheme
            "acrylicOpacity": 0.7,
            "useAcrylic": true
        },
        "list": [
            {
                // Make changes here to the powershell.exe profile.
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false,
                "startingDirectory": null
            },
            {
                // Make changes here to the cmd.exe profile.
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "Name": command prompt,
                "commandline": "cmd.exe",
                "hidden": false,
                "startingDirectory": null
            },
            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore",
                "startingDirectory": null
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure",
                "startingDirectory": null
            }
        ]
    },
    //Color scheme
    "schemes": [
        {
            "name": "Andromeda",
            "black": "#000000",
            "red": "#cd3131",
            "green": "#05bc79",
            "yellow": "#09da0f",
            "blue": "#2472c8",
            "purple": "#bc3fbc",
            "cyan": "#0fa8cd",
            "white": "#e5e5e5",
            "brightBlack": "#666666",
            "brightRed": "#cd3131",
            "brightGreen": "#05bc79",
            "brightYellow": "#09da0f",
            "brightBlue": "#2472c8",
            "brightPurple": "#bc3fbc",
            "brightCyan": "#0fa8cd",
            "brightWhite": "#e5e5e5",
            "background": "#262a33",
            "foreground": "#e5e5e5"
        },
        {
            "name": "Campbell",
            "foreground": "#F2F2F2",
            "background": "#0C0C0C",
            "colors": [
                "#0C0C0C",
                "#C50F1F",
                "#13A10E",
                "#C19C00",
                "#0037DA",
                "#881798",
                "#3A96DD",
                "#CCCCCC",
                "#767676",
                "#E74856",
                "#16C60C",
                "#F9F1A5",
                "#3B78FF",
                "#B4009E",
                "#61D6D6",
                "#F2F2F2"
            ]
        },
        {
            "name": "Solarized Dark",
            "foreground": "#FDF6E3",
            "background": "#073642",
            "colors": [
                "#073642",
                "#D30102",
                "#859900",
                "#B58900",
                "#268BD2",
                "#D33682",
                "#2AA198",
                "#EEE8D5",
                "#002B36",
                "#CB4B16",
                "#586E75",
                "#657B83",
                "#839496",
                "#6C71C4",
                "#93A1A1",
                "#FDF6E3"
            ]
        },
        {
            "name": "ayu",
            "black": "#000000",
            "red": "#ff3333",
            "green": "#b8cc52",
            "yellow": "#e7c547",
            "blue": "#36a3d9",
            "purple": "#f07178",
            "cyan": "#95e6cb",
            "white": "#ffffff",
            "brightBlack": "#323232",
            "brightRed": "#ff6565",
            "brightGreen": "#eafe84",
            "brightYellow": "#fff779",
            "brightBlue": "#68d5ff",
            "brightPurple": "#ffa3aa",
            "brightCyan": "#c7fffd",
            "brightWhite": "#ffffff",
            "background": "#0f1419",
            "foreground": "#e6e1cf"
        }
    ],
    "keybindings": [
        {
            "command": {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ]
}

More official colors

https://docs.microsoft.com/zh-cn/windows/terminal/customize-settings/color-schemes

Right click to add Windows terminal

<img style=”zoom:50%;” />

0x1 Download Icon

Download address:icon, put inC:\Users\[user_name]\AppData\Local\terminal, there is no new one for this folder.

be careful[user_name]It’s the user name of your computer

0x2 write to registry

Create a TXT document and change the file suffix toreg。 The name of the document can be created by yourself, and the suffix name cannot be wrong. The context menu appearsWindows TerminalThere are two ways. One is to pressshift+ Right clickThe other is directRight click

Shift + right click

Copy the following to reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal"
"Icon"="%USERPROFILE%\AppData\Local\terminal\wt_32.ico"
"Extended"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\Users\[user_name]\AppData\Local\Microsoft\WindowsApps\wt.exe"

be carefulPlease[user_name]Change to your computer’s user name

Right click

Copy the following to reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="%USERPROFILE%\AppData\Local\terminal\wt_32.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\Users\[user_name]\AppData\Local\Microsoft\WindowsApps\wt.exe"

be carefulPlease[user_name]Change to your computer’s user name

0x3 modify Windows terminal’s settings.json

holdprofiles > list > startingDirectoryChange tonullIf you don’t have one, create one yourself.

You can choose to change what you need. (I changed them all)

This is to change the right-click startup path to the current running command path.

Conclusion

Command line in normal workgitThe command is used more, and the extension is installedTabIt’s a lot of convenience. It’s automatic.

There are many ways to play the command line under windows, such as supporting linux commandsMSYS2, integratedpacman。 It can be referred toWin10 terminal artifact — integration of Windows terminal and msys2 mingw64Install.

0x8 reference link

About me

Sunseekerx, front-end development, nodejs development, appletuni-appDevelopment, etc

Like to discuss technical implementation scheme and details, perfectionist, can not seebug

Github:https://github.com/SunSeekerX

Personal blog:https://yoouu.cn/

Personal online notes:https://sunseekerx.yoouu.cn/