Sunday, August 08, 2021

A Great Book On Windows Terminal

 

Review of Will Fuqua’s book “Windows Terminal Tips, Tricks, and Productivity Hacks”


 

I have had the pleasure of reading through this recently published book (Smile.Amazon.Com). This is a timely book, full of tips and tricks for using the new Windows Terminal.

Ever since Microsoft got into the OS business, we’ve had a console or shell built into the OS. The earliest, command.com, gave way to cmd.exe with NT 3.1. And later came Windows PowerShell, the PowerShell ISE and of course PowerShell 7 with VS Code. And now we have Windows Terminal.

As the book clarifies, there really are two components at work when you use tools like PowerShell. The first is the shell, with the second being the terminal. As the book makes clear, the terminal is, essentially, “what you see” when you use a command-line tool. The terminal renders any text, draws any UI, and accepts kb/mouse input. The terminal sends input to the shell for the actual processing. The shell then processes the input and returns the results back to the terminal to display.

When you use cmd.exe or PowerShell, conhost.exe is the terminal with the command prompt or Windows Powershell/PowerShell 7 as the shell.  The actual shell does not have a UI as such – it gets input from and sends output to the terminal. It is important to separate the two.

Conhost.exe is really pretty primitive – it works and does the job but could do so much more. Which is a thought that has led to the development of a new, open-source, cross-platform terminal supporting just about any shell, including the shells in Linux distributions you can run under the Windows Subsystem for Linux (WSL2).  The new windows terminal is not just a re-write of conhost.exe, but is so much more!

As a PowerShell user, I traditionally used PowerShell via either the command line (i.e. pwsh.exe, cmd.exe, powershell.exe) or most often via VS Code (and some ISE).  The tool I chose at any given time reflected what I was about to do. I use a GUI to develop and test scripts. And sometimes to run code. On the other hand, when I only need to run code ( for example, my Get-TodayInHistory.ps1 script (https://github.com/doctordns/GDScripts/blob/main/Get-TodayInHistory.ps1) that helps me pick music to play today), I chose the console as my terminal.

The book begins with a look at both what the terminal is and how you install it, followed by a great chapter on the UI. If you are going to be using the new terminal, Chapter 2 has several important key sequences you need to work into your muscle memory.

In the second section, the book looks at how you can configure Windows Terminal and the shells you use. The book contains lots of great tips for using the terminal and PowerShell and WSL2 Ubuntu via Windows Terminal.

For the hardcore developer, the final section in the book looks at how you can use Windows Terminal in development. The book looks at using GIT and GitHub and building web applications (with React) and  REST APIs. The book finishes with a look at connecting to a remote host and managing hosts in the cloud by using Azure Cloud Shell or Google Cloud shell in the Windows Terminal.

If you are a casual terminal user, Windows Terminal does everything you used to use consoles for – and a lot more. Windows Terminal is a great tool if you are a WSL2 user, perhaps creating APIs or web apps. For both audiences (and everyone in between), this book provides great guidance, tips/tricks, and best practices.