Set up Windows Terminal shortcuts
And make Windows a bit more usable
September 18, 2020 ¡ Felipe Vogel ¡- Add a Windows Terminal submenu to the Explorer context menu
- Create a global hotkey for Windows Terminal
UPDATE, February 2023: Iâve now switched to Linux on my PC, and wrote a post about it. I wish I had made the switch sooner!
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, and 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:
- for cmd:
PowerShell -windowstyle hidden -Command "Start-Process cmd -ArgumentList '/s,/k,pushd,%V' -Verb RunAs"
- for PowerShell 7:
C:\Program Files\PowerShell\7\pwsh.exe -NoExit -RemoveWorkingDirectoryTrailingCharacter -WorkingDirectory "%V!" -Command "$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'"
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.