Book Image

Windows Terminal Tips, Tricks, and Productivity Hacks

By : Will Fuqua
5 (1)
Book Image

Windows Terminal Tips, Tricks, and Productivity Hacks

5 (1)
By: Will Fuqua

Overview of this book

Windows Terminal is a new and open-source command-line application for Windows 10, built for the Command Prompt, PowerShell, Windows Subsystem for Linux, and more. It's fast, modern, and configurable thanks to its GPU-accelerated rendering, excellent UTF-8 support, and JSON-based configurability, and this book can help you learn how to leverage these features. You’ll start by learning the benefits of Windows Terminal and its open-source development, as well as how to use the built-in tabs, panes, and key bindings to build your own efficient terminal workflows. After you’ve mastered Windows Terminal, this book shows how to use and configure PowerShell Core and the Windows Subsystem for Linux within Windows Terminal. You’ll maximize your productivity using powerful tools such as PSReadLine for PowerShell and ZSH on Linux, and discover useful tips and tricks for common developer tools like Git and SSH. Finally, you’ll see how Windows Terminal can be used in common development and DevOps tasks, such as developing frontend JavaScript applications and backend REST APIs, and managing cloud-based systems like Amazon Web Services (AWS), Microsoft Azure, and Google Cloud. By the end of this book, you'll not only be well-versed with Windows Terminal, but also have learned how to effectively use shells like PowerShell Core and ZSH to become proficient at the command line.
Table of Contents (20 chapters)
1
Section 1: Introducing the New Windows Terminal
5
Section 2: Configuring your Windows Terminal and its shells
12
Section 3: Using your Windows Terminal for development

The modern foundations of Windows Terminal

Earlier, we learned that Windows Terminal is built from the ground up to provide a more modern and flexible command-line experience. This command-line experience has three main parts: a modern UI, a flexible JSON-based customization system, and its open source development.

A Modern UI

When working with the command line, it's common to have a couple of command lines open. Perhaps a couple of operations need to be monitored at the same time, or some commands need to execute in PowerShell, and others need to use WSL. In the old terminal, the only option is to open separate windows and then Alt + Tab between them.

The new Windows Terminal comes with multiple options for managing these tasks. It features built-in tab support, each tab with its own shell, and all available within the same window:

Figure 1.2 – The new Windows Terminal with multiple shells open in tabs

Figure 1.2 – The new Windows Terminal with multiple shells open in tabs

Additionally, some operations work best with multiple shells open side by side. The old terminal again had no support for this; the only option was to use separate windows positioned next to each other. The new Windows Terminal supports "panes" that can open multiple different shells within the same tab. It's not just limited to two panes, either—the terminal supports multiple side-by-side panes split both vertically and horizontally:

Figure 1.3 – The new Windows Terminal with multiple shells open in a single tab

Figure 1.3 – The new Windows Terminal with multiple shells open in a single tab

We'll dive more into efficient tab and pane management in Chapter 2, Learning the Windows Terminal UI.

Improved visual effects

The modern UI features are not just limited to tabs and panes; the entire terminal has been written from the ground up to take advantage of the latest technology. The terminal itself is written using the Universal Windows Platform (UWP) framework with XAML Islands, and text rendering is handled by a GPU-accelerated rendering engine using DirectX.

This technology stack, in addition to being a flexible, fast, and solid foundation, enables improved visual effects as well. For example, the new Windows Terminal natively supports transparency using an effect called acrylic, as well as background images and GIFs:

Figure 1.4 – Left pane: PowerShell with the acrylic transparency effect. Right pane: cmd with a background image

Figure 1.4 – Left pane: PowerShell with the acrylic transparency effect. Right pane: cmd with a background image

Improved fonts and rendering

The new, GPU-accelerated rendering engine has all the modern features expected for a first-class command-line experience. The GPU acceleration results in ultra-fast and crisp text rendering, and the new rendering engine enables Unicode character support. While full, multi-language Unicode support is still a work in progress, the foundation is laid.

To show off the new Windows Terminal's font-rendering capabilities, Microsoft released a brand-new open source programming font named Cascadia Code, which is bundled in Windows Terminal:

Figure 1.5 – The Cascadia Code font at a selection of font weights

Figure 1.5 – The Cascadia Code font at a selection of font weights

Cascadia Code currently has support for a wide range of characters, including Cyrillic, Greek, and Vietnamese. It's open source, licensed under the SIL Open Font License, so progress for supporting additional languages can be tracked on GitHub, at https://github.com/microsoft/cascadia-code/.

Cascadia Code is called a programming font due to its support for optional programming ligatures. A ligature is a font feature that allows multiple characters to be rendered as a single glyph. For example, when typing the characters in the first row in the following image, they will be rendered as the bottom row:

Figure 1.6 – Top: characters as typed and stored. Bottom: ligatures as rendered

Figure 1.6 – Top: characters as typed and stored. Bottom: ligatures as rendered

In addition to programming ligatures, Cascadia Code also supports Powerline glyphs, a popular terminal customization that can improve the look of the command-line prompt, making it stand out from the input/output text around it:

Figure 1.7  –  Powerline prompt rendered using Cascadia Code PL

Figure 1.7 – Powerline prompt rendered using Cascadia Code PL

As mentioned, all these features are optional—the Cascadia font comes in four variations that allow enabling or disabling of both programming ligatures and Powerline glyphs:

Figure 1.8 – Cascadia font variations

Figure 1.8 – Cascadia font variations

We'll cover Powerline customization in detail in Chapter 5, Changing your Windows Terminal appearance.

Flexible JSON-based customization

Customization of the old terminal was quite frustrating; the options were distributed across both the Windows Registry and inside the shortcut files themselves! The new Windows Terminal fixes this and features a settings.json file with a documented schema.

The benefit of using a JSON file with a schema is two-fold: editors such as Visual Studio Code can provide a first-class editing experience with documentation and autocomplete, and the settings.json file can be version-controlled and easily shared across computers.

Figure 1.9 – Editing settings.json in Visual Studio Code, with autocompletion of available settings

Figure 1.9 – Editing settings.json in Visual Studio Code, with autocompletion of available settings

Additionally, the built-in Settings UI provides an easier way to customize the terminal. The Settings UI still uses the settings.json file behind the scenes, so the resulting configuration can still be easily shared and version controlled.

Figure 1.10 – The Settings UI in Windows Terminal

Figure 1.10 – The Settings UI in Windows Terminal

The settings.json file controls all aspects of the terminal, such as its themes and colors, keybindings, and window behavior. We'll dive deep into this file in Chapter 4, Customizing your Windows Terminal settings.

Open source development

The new Windows Terminal is open source! All development happens on Microsoft's GitHub repository, at https://github.com/microsoft/terminal/. The development team is incredibly active in this repository; bug reports, feature planning, and feature development happens in the open. Reading through this code repository, downloading the code, and even contributing to it is encouraged!

Figure 1.11 – The Windows Terminal GitHub repository

Figure 1.11 – The Windows Terminal GitHub repository

In addition to open source code, the documentation itself is open source. The documentation is hosted at https://aka.ms/terminal-docs, and clicking the Edit this Document link will navigate to the relevant document on GitHub. Edits to the documentation follow the typical pull request process, using Markdown for formatting.

The repository has hundreds of open source contributors, working on all aspects of the terminal. Several major features, such as background image support, have been added by the community. Whether it's improving documentation, submitting bug reports, or discussing and then adding features, feel free to get involved! Check out the CONTRIBUTING.md file in the GitHub repository to get started.

Now that we've covered the benefits of the new Windows Terminal, let's take our first step and get it installed!