Home Web Development Windows Terminal Tips, Tricks, and Productivity Hacks

Windows Terminal Tips, Tricks, and Productivity Hacks

By Will Fuqua
books-svg-icon Book
eBook $22.99 $15.99
Print $32.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $22.99 $15.99
Print $32.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Chapter 1: Getting started with the new Windows Terminal
About 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.
Publication date:
April 2021
Publisher
Packt
Pages
254
ISBN
9781800207561

 

Chapter 1: Getting started with the new Windows Terminal

At the Build 2019 conference, Microsoft made an exciting announcement: Windows 10 was getting a brand new command-line terminal! Custom built for the command prompt, PowerShell, and the Windows Subsystem for Linux, this new terminal promised to bring a modern, configurable, and open source command-line experience. In May 2020, Microsoft released the 1.0 version of the new Windows Terminal.

Windows Terminal is a separate application from the old Windows command line. This approach allows both terminals to live side by side, and enables Microsoft to rapidly release new features for Windows Terminal without endangering the backward compatibility of the old terminal.

By the end of this chapter, we will be up and running with Windows Terminal, having covered the following topics:

  • Why a new terminal?
  • The modern foundations of Windows Terminal
  • Installing Windows Terminal
  • Launching Windows Terminal

We'll cover why Windows needed a new terminal at all, how this new terminal is radically different from the old one, and take our first steps to download, install, and launch it.

 

Technical requirements

To get started with Windows Terminal, you'll need a Windows 10 installation with access to the built-in Microsoft Store application. The minimum version of Windows 10 supported is the May 2019 Update (version 1903, as reported in the output of the winver command). If you have a relatively up-to-date Windows 10 installation, you have all the tools you need to get started.

 

Why a new terminal?

Microsoft's old terminal, conhost.exe, has been showing its age. While it has seen some impressive improvements lately, such as ANSI/VT support and advanced settings, the primary goal of conhost.exe is to be backward-compatible with older applications. This backward-compatibility constraint can sometimes be at odds with the fast-paced improvements in other parts of Windows 10.

While both PowerShell and the shells running under Windows Subsystem for Linux (WSL) have been seeing constant, rapid improvement, the "user experience" of the Windows command line was in vast need of an upgrade, when compared to its macOS and GNU/Linux counterparts.

As we're getting started, it's useful to understand the difference between a terminal and a shell. A terminal is essentially "what you see" when using the command line—it renders the text, draws any user interface (UI) widgets, and accepts keyboard and mouse input. The terminal will then send this input to the shell for processing. The old terminal on Windows was called conhost.exe and was the only built-in terminal; however, there were and still are alternative third-party terminals such as ConEmu and Hyper.

A shell doesn't have a UI; it's a command-line program that receives input from the terminal, evaluates that input, and returns the result. Shells, such as the command prompt, PowerShell, and those running in WSL, require a terminal to collect input and display output. Launching the cmd.exe or powershell.exe shells from the Start menu or Run dialog will implicitly start the conhost.exe terminal, which can make the distinction less obvious for end users:

Figure 1.1 – PowerShell, running in both the old conhost on the left, and the new Windows Terminal on the right

Figure 1.1 – PowerShell, running in both the old conhost on the left, and the new Windows Terminal on the right

This delineation between terminals and shells means that switching to the new Windows Terminal is painless—the shells, such as the command prompt and PowerShell, are not changing. All existing knowledge and documentation of the command prompt, PowerShell, and shells under WSL can be reused, but commands will be sent through the new, more powerful Windows Terminal instead of the older, more barebones conhost.exe. Let's see what makes this new Windows Terminal so much better!

Note

A more in-depth discussion about the differences between shells and terminals can be found on Scott Hanselman's blog at https://www.hanselman.com/blog/whats-the-difference-between-a-console-a-terminal-and-a-shell.

 

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!

 

Installing Windows Terminal

There are several ways to get the new Windows Terminal. The easiest and recommended way is to install it from the Microsoft Store. The Microsoft Store is part of Windows 10 and will ensure we have a seamless installation experience. Updates to Windows Terminal are also delivered through the Microsoft Store.

Figure 1.12 – The Windows Terminal available in the Microsoft Store

Figure 1.12 – The Windows Terminal available in the Microsoft Store

  1. From the Windows Start menu, search for the Microsoft Store and open it.
  2. From inside the Microsoft Store, search for Windows Terminal.
  3. Select Windows Terminal and then click Get.
  4. Wait for Windows Terminal to download and install.
  5. Optionally, inside the Microsoft Store app, enable automatic updates by going to Settings and select Update apps automatically.

While this is the best way to both install the new Windows Terminal and ensure it stays up to date, there are several other ways to install Windows Terminal that might better fit certain automation scenarios:

  • Using the command-line winget installer:
    winget install --id=Microsoft.WindowsTerminal -e
  • Using the command-line chocolatey installer (unofficial):
    choco install microsoft-windows-terminal
  • Advanced users can download a pre-built release from GitHub, located at https://github.com/microsoft/terminal/releases. Install the Desktop Bridge VC++ v14 Redistributable Package as a dependency first.
  • Advanced users may also be interested in the Windows Terminal Preview application from the Microsoft Store, which can be installed alongside the Windows Terminal application. Windows Terminal Preview provides access to the latest features, though there may be some stability issues.

Now that we have Windows Terminal installed, let's start it up!

 

Launching Windows Terminal

It's worth spending some time reviewing how to efficiently start our Windows Terminal, as it's something we'll be doing frequently!

The normal way to start Windows Terminal is to select it from the Start menu, either by selecting the icon using the mouse or typing out the words windows terminal in the Start menu search bar.

Luckily, there are faster ways. Windows Terminal ships with a binary, wt.exe, that can be used to quickly start the terminal. Press wt<enter> from the Start menu, Run dialog, or Windows Explorer location bar to open the terminal. wt.exe has several interesting command-line flags, such as -F to launch in fullscreen mode. We'll learn more about the capabilities of wt.exe in Chapter 6, Setting up keyboard shortcuts.

An additional way to start Windows Terminal is to use the taskbar keyboard shortcuts, such as Win + 1, Win + 2, and so on. Pin the application to the taskbar by finding the Windows Terminal application in the Start menu, right-clicking it, and choosing Pin to taskbar. Then, on the taskbar, drag the Windows Terminal icon all the way to the left so it's the leftmost icon. Now, pressing Win + 1 will launch Windows Terminal, or bring it into the foreground if it's already open:

Figure 1.13 –Windows Terminal pinned to the taskbar in the first position

Figure 1.13 –Windows Terminal pinned to the taskbar in the first position

Now that we have the Windows Terminal pinned to the taskbar, we can right-click on the icon to open a Jump List Menu, where we can open Windows Terminal directly to our desired shell:

Figure 1.14 – The Windows 10 Jump List for the Windows Terminal

Figure 1.14 – The Windows 10 Jump List for the Windows Terminal

The final way we'll learn to open Windows Terminal is from Windows Explorer. Open Windows Explorer (Win + E) and then right-click any directory. Select the Open in Windows Terminal menu item to open that directory in Windows Terminal. Additionally, right-clicking or pressing Shift and right-clicking on the background of Windows Explorer shows an Open Windows Terminal here menu option that will open the current directory in Windows Terminal:

Figure 1.15 – The Open in Windows Terminal context menu item

Figure 1.15 – The Open in Windows Terminal context menu item

 

Summary

In this chapter, we learned the differences between a terminal and a shell. We discussed how the new Windows Terminal has several key benefits over the older conhost.exe, including a modern, GPU-accelerated UI, a flexible JSON-based configuration system, and an open source community. In addition, we learned a few ways of installing the new Windows Terminal, as well as how to efficiently launch it from anywhere in Windows 10.

In the next chapter, we'll learn how to effectively use Windows Terminal. We'll cover all major components of Windows Terminal, including the terminal tabs, panes, and interacting with various shells. We'll also cover a few interesting keyboard shortcuts, as well as the new command palette feature.

 

Further reading

If you found the discussion of terminals versus shells interesting, you may also enjoy reading about ConPTY—the new modern console infrastructure that enabled Windows Terminal to be possible in the first place! Rich Turner, when he was the Senior Program Manager of Windows Console and Command Line, wrote an excellent blog post series titled Windows Command-Line that walks through the nitty-gritty details: https://devblogs.microsoft.com/commandline/windows-command-line-backgrounder/.

If you're interested in learning more about the modern technology powering the new Windows Terminal, check out Building Windows Terminal with WinUI by Kayla Cinnamon, the Program Manager of Windows Terminal, Console, Command Line, and Cascadia Code: https://devblogs.microsoft.com/commandline/building-windows-terminal-with-winui/.

About the Author
  • Will Fuqua

    Will Fuqua has been developing software professionally for 12 years using a wide range of technologies. Initially based in the United States as a software consultant, he developed production systems for companies in the healthcare and finance industries, among many others. He then moved abroad and is now the Head of Engineering for an online travel agency, where he leads a high-powered technology team out of Bangkok, Thailand.

    Browse publications by this author
Windows Terminal Tips, Tricks, and Productivity Hacks
Unlock this book and the full library FREE for 7 days
Start now