Add Windows Terminal to the Right-click Menu

Windows Terminal is now available on the Microsoft Store, so I switched from Fluent Terminal to Windows Terminal. Here's a record of the process to add it to the right-click menu.

Windows 11 has now default added 'Open in Terminal' in the right-click menu, so there's no need to add it separately. If you've already added it, you can simply delete [HKEY_CLASSES_ROOT\Directory\Background\shell\wt] from the registry.

Adding an Icon

First, create a folder named ‘Terminal’ in C:\Users\[YOUR_USER_NAME]\AppData\Local. You can create it directly using the following command. Make sure to replace [YOUR_USER_NAME] with your own username!

1
mkdir C:\Users\[YOUR_USER_NAME]\AppData\Local\Terminal

Next, download the Windows Terminal icon to the folder you just created. If your browser doesn’t automatically download it, right-click and choose “Save as” to save it as ‘terminal.ico’.

terminal.ico Download

Registry Entry

Create a new text file and add the following content. Then, change the file extension to .reg. Remember to replace [YOUR_USER_NAME] with your own username!

1
2
3
4
5
6
7
8
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows terminal here"
"Icon"="C:\\Users\\[YOUR_USER_NAME]\\AppData\\Local\\Terminal\\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\[YOUR_USER_NAME]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"

Once done, double-click the file to merge it into the registry.

Modifying Configuration

At this point, you should already see the ‘Windows terminal here’ option in the right-click menu. However, when you click it, the terminal does not open in the current directory. To change this behavior, you need to modify the configuration file of ‘Windows Terminal.’

Open ‘Windows Terminal,’ click the top dropdown menu, and select ‘Settings.’ This will open the configuration file named ‘settings.json.’ The section you need to modify is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
},
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "命令提示符",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
]
},

To launch ‘Windows Terminal’ in the current folder, you need to add "startingDirectory": "./" below each section you want to modify. After making the changes, it should look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
},
"list":
[
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"startingDirectory": "./"
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "命令提示符",
"commandline": "cmd.exe",
"hidden": false,
"startingDirectory": "./"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure",
"startingDirectory": "./"
}
]
},

After saving these changes, you’ll be able to use the right-click menu to run ‘Windows Terminal’ in the current folder.

Possible Issue

When using PowerShell, you may encounter an error message that says, “Cannot load file balabala.ps1 because running scripts is disabled on this system. For more information, see…” This is because the default ExecutionPolicy is set to “Restricted,” which means it doesn’t allow the execution of any scripts.

The solution is to run PowerShell as an administrator and enter the command set-executionpolicy remotesigned to lift the restriction.

References:

  1. https://github.com/microsoft/terminal/issues/1060#issuecomment-497539461
  2. https://blog.csdn.net/Jioho_chen/article/details/101159291