Wechat search [front-end full stack developers] pay attention to this hair loss, stall, sell goods, continue to learn programmers, the first time to read the latest articles, will give priority to two days published new articles. Pay attention to the gift package, you can save a lot of money!

In this article, we’ll look at Windows Terminal, which is an ideal companion to WSL2. It’s fast, configurable, good-looking, and offers all the benefits of Windows and Linux development.

Windows has fully embraced Linux, and WSL2 makes it seamless fun.

You can access the distribution terminal in the following ways:

  1. Click its Start menu icon
  2. Enter at Powershell or a command promptwslbash
  3. By starting% windir % \system32\bash.exe ~Using third-party terminal options (such as Cmder, ConEmu, and Hyper)
  4. To set Linux as the default shell in VS Code, pressCtrl + Shift + P, then enter/select terminalTerminal: Select Default Shell, and selectWSL Bash.

Windows Terminal offers more options, but you won’t regret installing it. New application features.

  • Support for WSL2, SSH, Powershell, CMD and other command lines
  • Multiple tabs and split panes
  • The search box
  • Custom key binding
  • GPU accelerated text rendering
  • Beautiful new font Cascadia Code
  • Low resource usage (usually 10MB per option card)
  • Automatic updates (if using Microsoft Store)
  • Good documentation
  • It’s open source!

How do I install Windows Terminal

The easiest way to install Windows Terminal is through the Microsoft Store:

ms-windows-store://pdp/? ProductId=9n0dx20hk701Copy the code

If this link fails, try opening Microsoft Store ina browser, or start the Microsoft Store application from the Windows Start menu and search for Terminal.

Note: Be careful not to select the earlier Windows Terminal Preview app.

Click Get and wait a few seconds for the installation to complete.

If you don’t have access to the store, you can download the latest version from GitHub.

The Windows Terminal application icon is now available in the Windows Start menu. For easy access, right-click the icon and choose Lock to Start or More, then select Lock to taskbar.

Introduction to Windows Terminal

When first run, Windows Terminal starts with Powershell as the default configuration file. Dropdown menus can be used to launch other tabs and access Settings:

The terminal will automatically generate configuration files for all WSL distributions and Windows shells you install, although you can disable build in global Settings.

Manage tabs and panes

Open a new TAB for the default profile by clicking the + icon or Ctrl + Shift + T. To open a TAB for another profile, select that TAB from the drop down menu or press Ctrl + Shift + N, where N is the profile number.

Press Alt + Shift + D to copy and split the pane. Each time you use it, the active pane is divided into two parts along the longest axis:

Force creation:

  • In the vertical pane, pressAlt + Shift + +
  • Horizontal pane, pressAlt + Shift + -

To open another profile in a new pane, hold down the Alt key while selecting from the drop-down menu.

Hold down the Alt key, then use the cursor keys to switch between the active panes on the keyboard. You can resize the pane by holding down Alt + Shift and using the cursor keys to resize accordingly.

You can rename a TAB by double-clicking on the text, and you can also change the name or color by right-clicking on the label and selecting menu options:

This only affects the current TAB; It does not permanently change personal data.

To close the active pane or TAB, press Alt + Shift + W or enter the terminal’s standard exit command (usually exit).

The font size

You can use Ctrl + + and Ctrl + – to resize the text on the active terminal. Alternatively, hold Ctrl and scroll the mouse wheel.

rolling

Use scrollbars to browse terminal output. Alternatively, use keyboard navigation by holding Down the Ctrl key and pressing cursor Up, cursor Down, Page Up, or Page Down.

search

Press Ctrl + Shift + F to open the search box:

Enter any term, then search the terminal output using the up and down ICONS. Click the Aa icon to activate or deactivate exact case matching.

Copy and paste

By default, copy and paste are bound to Ctrl + Shift + C and Ctrl + Shift + V, respectively, although Ctrl + C and Ctrl + V also work.

Note: Be aware that Ctrl + C can terminate Linux applications, so Shift is recommended.

Global Settings provides an automatic copy option when selected, and you can also right-click to paste the current clipboard item.

configuration

Settings can be accessed from the drop-down menu or Ctrl +, (comma). This configuration is defined in a single settings.json file, so you may be prompted to select a text editor. VS Code is a good choice, but if you want to edit without color coding and syntax checking, Notepad will do the job.

Settings. Json controls:

  • Global Settings Global Settings, applicable to all configuration files
  • Profile Settings Settings used to define the profile
  • Custom Color Scheme Settings custom Color Scheme Settings and KeyBinding Settings

This file uses the following format:

// This file was initially generated by Windows Terminal
{

  // general settings, e.g.
  "initialRows": 40.// profile settings
  "profiles":
  {

    "defaults":
    {
      // settings that apply to all profiles
    }
    "list":
    [
      // list of individual profiles, e.g.
      {
        "guid": "{81d1dceb-c123-5678-90a1-123abc456def}"."name": "Windows PowerShell"."commandline": "powershell.exe"
      },
      {
        "guid": "{91d1dceb-c123-5678-90a1-123abc456def}"."name": "Ubuntu"."source": "Windows.Terminal.Wsl"}}]// custom color schemes, e.g.
  "schemes": [{"name": "My new theme"."cursorColor": "#FFFFFF"."selectionBackground": "#FFFFFF"."background" : "#0C0C0C"."foreground" : "#CCCCCC"}].// custom key bindings, e.g.
  "keybindings: [ { "command":"find","keys":"ctrl+shift+f"}}]Copy the code

The default value is defined in defaults.json. When you click Settings in the drop-down menu, hold down Alt to turn it on.

Warning: Do not change the default file! Use it to view the default Settings and add or change them in settings.json as necessary.

Global configuration

The following global Settings are the most useful, although more global Settings are documented in the Windows terminal documentation.

DefaultProfile defines the GUID that will be used as the defaultProfile when starting Windows Terminal.

Setting copyOnSelect to true automatically copies selected text to the clipboard without pressing Ctrl + Shift +C.

Set copyFormatting to false to copy plain text without any styling. (I want this to be the default setting for all apps!)

Set initialColumns and initialRows to the number of characters with horizontal and vertical dimensions.

You can set tabWidthMode to:

  1. equal: The same width for each TAB (default)
  2. titleLength: Each label is set to the width of its title, or
  3. compact: Inactive tabs shrink to the width of their ICONS.

DisabledProfileSources sets an array to prevent automatic profile generation. Such as:

"disabledProfileSources": [
    "Windows.Terminal.Wsl"."Windows.Terminal.Azure"."Windows.Terminal.PowershellCore"].Copy the code

This will disable all generated profiles and remove any you want to keep.

Profile Profile Settings

Define a new profile by creating an object group in the profile, list array. An example of WSL2 Ubuntu.

{
  "guid": "{91d1dceb-c123-5678-90a1-123abc456def}"."name": "Ubuntu"."source": "Windows.Terminal.Wsl"."startingDirectory": "//wsl$/Ubuntu/home/username/"."colorScheme": "Tango Dark"."useAcrylic": true."acrylicOpacity": 0.75."hidden": false
},
Copy the code

Each profile is defined with the following Settings:

Set up the describe
guid Unique identifier (mandatory). For new configuration files, you can generate guids online at Guidgen.com.
source Configuration file generator. Use only when a configuration file has been added automatically and cannot be edited.
commandline Assume an executable run without “source” set. For example, this could be an SSH command, such as “[email protected]
startingDirectory Shell start directory. For WSL distributions, it is best to set this to “// WSL $/Ubuntu/home/username/”, where username is the user created during installation
name The name of the profile displayed in the drop-down menu
tabTitle The name displayed in the label title
suppressApplicationTitle Set to true to force “tabTitle” or “name” in bash
icon Full paths to ICONS displayed in drop-down menus and tabs, such as C:/images/tux.png. A 24-bit PNG is the best choice; Unfortunately, SVG is not supported
hidden If set to true, the configuration file will not be displayed in the drop-down menu
fontFace Use a specific font
fontSize Use a specific font pound to value integers
fontWeight Use a specific font thickness. This can be an OpenType integer or a keyword:"normal"."thin"."extra-light"."light"."semi-light"."medium"."semi-bold"."bold"."extra-bold"."black"."extra-black"
padding Fill around the text at the edge of the window. You can set one, two, or four comma separated values, such as “1, 2, 3, 4” for left, up, right, and down, respectively
antialiasingMode Anti-aliasing method. Set to “grayscale” (default), “ClearType”, or “aliased”.
cursorShape Cursor type. Set to “bar” (default), “vintage”, “underscore”, “filledBox”, or “emptyBox”
cursorHeight The height of the “vintage” cursor, defined as an integer between 25 and 100
cursorColor Cursor color, defined as “# RGB” or “# RRGGBB”

Theme-specific Settings include:

Set up the describe
colorScheme The name of the color scheme defined in the Scheme list in defaults.json or settings.json (see below)
useAcrylic Set to True to use the frosted glass background effect
acrylicOpacity Acrylic’s opacity ranges from 0 (fully transparent) to 1 (completely opaque).
backgroundImage The full path of the background image, for example “C:/images/background.png”
backgroundImageOpacity The opacity of the background image goes from 0 (full opacity) to 1 (full opacity)

Finally, in the configuration file to add “experimental. RetroTerminalEffect” : true, restoring ancient ways to achieve the effect of the CRT. …

Color scheme Settings

You can set the “colorScheme” of each profile to the name of any colorScheme contained in defaults.json. Such as:

“Campbell”

“Campbell Powershell”

“One Half Dark”

“One Half Light”

“Tango Dark”

“Tango Light”

“Vintage”

Create your own color scheme

You can define your own schema objects in the “Schema” array in settings.json. Each color is defined as a hexadecimal value. Such as:

"schemes": [{"name": "My New Theme"."foreground": "#EEEEEE"."background": "# 111111"."cursorColor": "#FFFFFF"."black": "# 000000"."red": "#CC0000"."green": "#4E9A06"."yellow": "#C4A000"."blue": "#3465A4"."purple": "#75507B"."cyan": "#06989A"."white": "#EEEEEE"."brightBlack": "# 555753"."brightRed": "#EF2929"."brightGreen": "#8AE234"."brightYellow": "#FCE94F"."brightBlue": "#729FCF"."brightPurple": "#AD7FA8"."brightCyan": "#34E2E2"."brightWhite": "#FFFFFF"}].Copy the code

You can then use the scheme by adding its “name” to the “colorScheme” setting in the configuration file. Such as:

"colorScheme": "My New Theme"
Copy the code

Keyboard binding Settings

The “keybindings” array in settings.json overrides or complements the default keybindings set in defaults.json. Each key binding is defined as an object with a combination of “command” and “keys”. Such as:

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

In some cases, “command” can be an application “action” with one or more parameters. Such as:

// Ctrl + Shift + 1 to open the first profile in a new tab
{
  "command": { "action": "newTab"."index": 0 },
  "keys": "ctrl+shift+1"
},
Copy the code

The “keys” value takes the modifiers CTRL +, shift +, and Alt +, followed by:

type keys
The function keys f1-f24
Alphanumeric key a-z.0-9
The symbol key -. =. [. ].\. ;.. ,. .. /
The cursor keys down.left.right.up. pagedown.pageup.pgdn. pgup. end. home. plus
The action key tab.enter.esc.escape.space.backspace.delete.insert
The keypad numpad_0-numpad_9, numpad0-numpad9, numpad_add, numpad_plus,

numpad_decimal, numpad_period, numpad_divide,

numpad_minus, numpad_subtract, numpad_multiply

For example, if you want to open the search box with Ctrl + F, you can add a line in the “KeyBindings” array in settings.json: TAB

"keybindings": [{"command": "find"."keys": "ctrl+f"}]Copy the code

The search box will also open with Ctrl + Shift + F, as this setting is defined in defaults.json — unless you assign the key combination to another command.

Command-line options

You can start a Windows terminal from a shortcut or from any Windows or Linux terminal by running wt.exe. The following options are supported:

options describe
- help.-h.-?./? Display help
- maximized.-M Startup maximum
- fullscreen.-F Start the full screen

You can also pass a list of commands separated by semicolons. Commands are used to define new tabs and panes and other control parameters:

The command parameter
new-tab - the profile or -p.- startingDirectory or -d.commandline.- the title Open a new TAB
split-pane --horizontal or -H.- vertical or -V.- the profile or -p.- startingDirectory or -d.commandline.- the title A new pane opens
focus-tab - target or -t Focusing on the label

example

The following example must be executed from the standard CMD command line or a shortcut.

Open a Windows terminal using the Ubuntu and Windows Powershell tabs:

wt -p "Ubuntu" ; new-tab -p "Windows PowerShell"
Copy the code

Open a Windows terminal using Ubuntu, Windows Powershell, and command prompt configuration files in a separate pane:

wt -p "Ubuntu" ; split-pane -V -p "Windows PowerShell" ; split-pane -H -p "Command Prompt"
Copy the code

More examples for starting Windows Terminal from a Linux Shell or Powershell are provided in the Windows Terminal documentation.

conclusion

Hope you enjoyed this introduction to Windows terminals. As stated, it is an ideal complement to WSL2. It’s fast, configurable, good-looking, and offers all the benefits of Windows and Linux development.


Original: www.sitepoint.com/windows-ter…

By Craig Buckler