Set up Windows Terminal shortcuts

And make Windows a bit more usable

September 18, 2020 ¡ Felipe Vogel ¡

UPDATE April 2021: Disregard my rueful comments below, because development on Windows is a breeze now that I’ve started using WSL (Windows Subsystem for Linux). It’s so easy to set up that I regret not doing so as soon as I learned about it last year. Dilapidated Windows builds of development tools are now a thing of the past for me. Hallelujah!

Today’s productivity how-to: set up context menu shortcuts and a global hotkey for the new Windows Terminal.

But first, the obvious confession: I use Windows. I don’t love Windows; it’s just that the effort of switching has never seemed justified, when I’d only be trading my Windows annoyances for a new set of problems that inevitably comes with any OS.

So I’ve stuck with Windows—despite the mockery of Apple devotees, despite the scornful grimaces of Linux hackers. Despite the occasional pain of setting up development tools, when the installation instructions consist of a single sentence on how to install the latest version in Linux or MacOS, followed by that familiar line: “Windows users, click here for a Windows build that some bozo put together for your crappy OS. Oh, and it’s from five years ago.”

There are some hopeful signs, though. Windows is finally getting a native package manager, and the Windows Subsystem for Linux has been out for a while now.

Another welcome relief is Windows Terminal. No more juggling five windows of three different consoles: Windows Terminal has tabs and panes. It’s faster than the third-party terminals I’ve tried. It’s also quick to open, with context menu shortcuts and a global hotkey to open up a terminal in the current directory.

… Wait, say again? Windows Terminal doesn’t have context menu shortcuts? No hotkey, either? Sigh… Here’s how you can supply those missing pieces.

Add a Windows Terminal submenu to the Explorer context menu

Fortunately, some kind souls have done most of the work already with a PowerShell script to install context menu items for Windows Terminal. However, it didn’t quite work for me, so here’s what I changed.

Tweak the registry location. If you follow the instructions with no results, try this: in “install.ps1” replace HKEY_CURRENT_USER\SOFTWARE\Classes\Directory with HKEY_CLASSES_ROOT\Directory.

Replace admin mode commands. If the “as administrator” menu items don’t work, try this: in the registry editor, go to “HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuTerminalAdmin\shell” and replace the value in each “command” key with these:

Unfortunately, these commands open Command Prompt and Powershell rather than Windows Terminal… but for me it doesn’t matter because I typically use gsudo in a regular Windows Terminal anyway (more on that below).

Add profiles for other command lines that you use. For example, add a WSL profile.

Create a global hotkey for Windows Terminal

If you’re a keyboard junkie, surely you don’t want to muck around with a context submenu—how plebeian! So here’s an AutoHotkey script that opens the terminal with a default starting directory, or with the current directory if an Explorer window is in focus.

#CommentFlag //
#NoEnv  // Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  // Recommended for new scripts due to its superior speed and reliability.
profile = Felipe  // replace with your user profile name

F13 & r::  // i.e. #r (LWin+R) thanks to SharpKeys
// if an Explorer window is not active
If !(WinActive("ahk_class CabinetWClass"))
  // or write in your own default directory after -d
  Run "C:\Users\%profile%\AppData\Local\Microsoft\WindowsApps\wt.exe" -d "C:\"
Else {  // open to the current directory in Explorer
  WinGetTitle, Title, A
  if (Title = "Downloads") {
    Title = "C:\Users\%profile%\Downloads"
  }
  Run "C:\Users\%profile%\AppData\Local\Microsoft\WindowsApps\wt.exe" -d "%Title%"
}
Return

(You may be raising an eyebrow at my odd hotkey F13 + R. Actually it’s Windows + R, after remapping the Windows key to F13 with SharpKeys. If you’ve ever wondered how to get rid of those pesky Windows shortcuts and turn the Windows key into an extra modifier key, there you have it. For more on that, see my next post on AutoHotkey.)

For executing commands with elevated privileges, I like using gsudo from within a regular (non-admin) terminal. If you really want a separate hotkey to open the terminal as administrator, you’ll need to choose from a few workarounds.

And with that, you have a respectable terminal even in Windows. Coming up next: supercharge your keyboard (and your mouse!) with AutoHotkey.

👉 Next: AutoHotkey - Windows key, home row arrow keys, mouse shortcuts 👈 Previous: Track your reading with read.csv 🚀 Back to top