2

I would like to use the "Open in Windows Terminal" context menu installed together with Windows Terminal, but with some command line arguments in it.

Specifically, I would like to add the argument -w 0, which opens the terminal in the same window already opened.

How do I do that?

Edit

Following Señor CMasMas answer: I know how to add a new option in the context menu by adding a new entry in the registry
Computer\HKEY_CLASSES_ROOT\Directory\Background\shell\

or, if you're not adim: Computer\HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background\shell\

But I'd like rather to modify the existing option by simply adding the arguments. Is that possible?

Edit 2

Now I was told that there is an option in settings to open the terminal in the same window, achieving what I was looking for:

the terminal in the same window

But the general situation of including other command line arguments may follow the answer.

Diogo
  • 123
  • 5

2 Answers2

2

Because this is a "windows app" and not a NORMAL app, the shell integration is a bit wonkie.

You will need to disable the original entry and re-create it using the "old way" as the new way is a shell extension and provides you with no control (that I can find).

First, disable the original entry(s):

  1. Open the registry editor.
  2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked
  3. Add two new EMPTY string values. {9F156763-7844-4DC4-B2B1-901F640F5155} and {02DB545A-3E20-46DE-83A5-1329B1E88B6B}.

Now, re-add the entries you want with whatever custom parameters you want.

  1. Open the registry editor.
  2. Navigate to Computer\HKEY_CLASSES_ROOT\Directory\shell
  3. Right click shell -> New Key
  4. Name openwinterm (or whatever makes you happy)
  5. In the new key, open the (Default) value and put Open Windows Terminal Here.
  6. Create one addition string value here named "Icon". Make it's value C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.13.11431.0_x64__8wekyb3d8bbwe\wt.exe. This might change over time.. it points at the icon file.
  7. Right click "openwinterm" -> new key
  8. Name key command
  9. Open the (Default) key and put wt.exe -w 0 -d "%V"
  • I wasn't successful with this procedure. Here is some questions to clarify: (1) You suggest I add a new entry in the context menu instead of modify the already existing one, right? (2) If that is true, I would like to also remove the existing one, because I don't want to stay with 2 "open in" commands in the context menu (3) I believe you mentioned how to remove, but I could not trim out the existing one command with the step you mentioned, I think Windows Terminal is not in that registry key (4) What the value @wt.exe,-2 does exactly? It didn't do anything in my case. – Diogo Jul 14 '22 at 03:58
  • Finally, I was expecting a way to modify the already existing command including the arguments, because it is already set, with an icon, the position and everything. Is there really no way to achieve that? – Diogo Jul 14 '22 at 04:00
  • 1
    My problem was that this app has changed over time. It "used to be" a normal app. Now it is a "universal app"/"windows app".. I had to jump through some hoops to figure this out. You CANT modify the existing one in any way that I can figure out as it is now a shell extension that puts the entry there. What I suggest above should give you the same functionality. – Señor CMasMas Jul 14 '22 at 17:28
  • Thanks for the information and the answer – Diogo Jul 14 '22 at 17:33
2

OK got it working. first DON'T download the MsixBundle, it does stupid stuff with the installation. the terminal gets installed to some weird folder with extreme security settings. I cant mess with it even as an admin. instead just get the dumb zip file, like this:

https://github.com/microsoft/terminal/releases/download/v1.18.2822.0/Microsoft.WindowsTerminal_1.18.2822.0_x64.zip

extract to wherever, for example:

C:\terminal-1.18.2822.0

then save the below as INSTALL.REG:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\background\shell\terminal\command]
@="C:\\terminal-1.18.2822.0\\WindowsTerminal.exe"

and you can fix the starting folder like this:

{
   "profiles": {
      "defaults": {"startingDirectory": ""}
   }
}

done. Microsoft making stuff WAY harder than it needs to be.