wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Bring "Open Wezterm Here" menu item on Windows 11 context menu

Open blue-devil opened this issue 2 years ago • 12 comments

Describe the solution you'd like Windows 11 brings a new context menu and if you want you can switch to old Windows 11 context menu. On new windows 11 context menu Windows Terminal comes by default. But after installing Wezterm, Open Wezterm Here context menu item only appears in old win10 context menu.

Here is a gif:

win11weztermcntxmn

Is there a way to bring wezterm to Win11 context menu. Can you make it default when we install wezterm.

Thank you.

blue-devil avatar May 26 '23 12:05 blue-devil

Anyone can bring old windows 10 menu by using this by using this reg file:

https://gitlab.com/-/snippets/2547911

But I do not want that. I want wezterm menu item on windows 11 context menu. Thank you.

blue-devil avatar May 26 '23 12:05 blue-devil

If you (or someone else) can find out what APIs and/or registry stuff is needed to make it show up there, then that gives us a starting point for this.

wez avatar May 26 '23 20:05 wez

In my next free time, I will look for this 👍

blue-devil avatar May 26 '23 20:05 blue-devil

After doing some digging, it seems an app must either be packaged in the MSIX format, or granted identity (1) via other methods to appear on the condensed Windows 11 context menu. I was able to easily bundle the existing WezTerm installer (2) as an MSIX package with the MSIX Packaging Tool (3) as a test, but I believe to appear on the context menu it needs to implement a shell extension as the registry is virtualized for MSIX apps.

If you package your Windows app using MSIX, the registry is virtualized, and therefore your app can't register File Explorer extensions via the registry. (4)

Either packaging method would likely require a shell extension implementation for anything other than a file type association. Definitely not a trivial task just to save one button click!

(1) Grant package identity to non (MSIX) packaged apps (2) Create an MSIX package from any desktop installer (3) MSIX Packaging Tool (4) Integrate with File Explorer

cmattinson avatar Jul 06 '23 05:07 cmattinson

If a COM shell extension is required for this, it seems like it would make sense to also consider registering as a default terminal at the same time, which AFAIU, also requires a COM shell extension:

  • https://github.com/wez/wezterm/issues/2416

wez avatar Jul 06 '23 18:07 wez

im willing to create if people are still interested in this if you like @wez

DevX-Cipher avatar Jun 12 '24 11:06 DevX-Cipher

@modz2014 I would love to see a PR for this, yes!

wez avatar Jun 12 '24 13:06 wez

@wez I will work on this also for the msix package you will need to get it signed I can make an external package spare package or msix package with the full software in it If you would like to chat about it please DM on Discord modz2014#4684

DevX-Cipher avatar Jun 12 '24 14:06 DevX-Cipher

I'd prefer that the solution to this gets deployed as part of the existing iss installer. re: code signing, we don't have that in place yet. Maybe https://github.com/Azure/trusted-signing-action/issues/10 will have a path for that.

wez avatar Jun 12 '24 14:06 wez

@wez possibly but this section will be yours as its your project also if you create the full msix package and upload it to the Microsoft store they sign it for us

DevX-Cipher avatar Jun 12 '24 14:06 DevX-Cipher

@wez here is an example for i just created now but I need to create a msix package project in visual studio or I can make a batch script to build the msix package and sign it for testing it image

DevX-Cipher avatar Jun 12 '24 16:06 DevX-Cipher

@wez i have made it in C++ is that ok no

DevX-Cipher avatar Jun 13 '24 07:06 DevX-Cipher

https://github.com/user-attachments/assets/a70ce01e-ecf3-46ed-a0ca-343541f1ef81

https://github.com/user-attachments/assets/568408da-bc61-4bd2-9a15-879f77b5f2e3

To have these in you explorer follow the below steps:

  1. Install nilsoft shell
  2. Run it as administrator
  3. Click Register
  4. Shift + Right click in taskbar
  5. shell > config
  6. Before the lastline (i.e. import/taskbar) insert the below code snippet

item(title="nvim" tip=tip_run_admin admin=has_admin cmd='wezterm.exe' args='start --cwd "@sel.dir" nvim')

item(title="wezterm" tip=tip_run_admin admin=has_admin cmd='wezterm.exe' args='start --cwd "@sel.dir"')

  1. Save the file
  2. Shift + Right click taskbar
  3. shell > manager
  4. Click Restart Explorer

If you need logo like mine and the below logos in "~ \documents\logo' nvim wezterm

Change the code to

item(title="nvim" tip=tip_run_admin admin=has_admin image="C:\\Users\\{Username}\\Documents\\logo\\nvim.png" cmd='wezterm.exe' args='start --cwd "@sel.dir" nvim')

item(title="wezterm" tip=tip_run_admin admin=has_admin image="C:\\Users\\{Username}\\Documents\\logo\\wezterm.png" cmd='wezterm.exe' args='start --cwd "@sel.dir"')

atheeq-rhxn avatar Jul 23 '24 14:07 atheeq-rhxn

[Note from wez: this is handled already by the setup.exe installer of wezterm, and wez doesn't recommend doing this "by hand". This is NOT what is being requested in this thread, so I'm going to hide this particular comment.]

Add WezTerm on Windows context menu (right click)

  1. Open Registry Editor:
    • Press Win + R, type regedit, and hit Enter.
    • (or find Registry Editor)
  2. Navigate to the Right Registry Key:
    Go to:
Computer\HKEY_CLASSES_ROOT\Directory\Background\shell

(This is for adding it to the right-click menu when clicking on empty space in a folder.)

  1. Create a New Key:
    • Right-click shell, select New → Key, and name it:
Open with WezTerm
  1. Modify the Default Value (Optional):
    • Select the newly created key (Open with WezTerm).
    • In the right panel, double-click (Default) and set its value to:
Open in WezTerm

(This is the text that will appear in the context menu.)

  1. Add an Icon (Optional):
    • Right-click on Open with WezTerm, select New → String Value, and name it Icon.
    • Double-click Icon and set its value to the path of WezTerm's executable, for example:
C:\Program Files\WezTerm\wezterm-gui.exe
  1. Create the Command Key:
    • Right-click Open with WezTerm, select New → Key, and name it:
    command
    
    • In the right panel, double-click (Default) and set its value to: default:
"C:\Program Files\WezTerm\wezterm-gui.exe" start --no-auto-connect --cwd "%V

or:

"C:\Program Files\WezTerm\wezterm.exe" start --cwd "%V

(Adjust the path if WezTerm is installed in a different location.)

Result:

Image

YaroslavShilov avatar Feb 14 '25 09:02 YaroslavShilov

this isn't for the new context menu @YaroslavShilov

DevX-Cipher avatar Feb 14 '25 10:02 DevX-Cipher

On Windows 11, i use: item(title='Wezterm' image='wezterm-gui.exe' tip=tip_run_admin admin=has_admin cmd='wezterm-gui.exe' args='start --cwd "@sel.path"'). But it always opens in my home directory (C:\Users\MYUSER), no matter where I start the context menu from.

kremec avatar Feb 19 '25 10:02 kremec

@modz2014 Did you actually make a COM shell extension? how?

nichoj10 avatar Mar 05 '25 15:03 nichoj10

@nichoj10 @blue-devil @wez i have created a pull request WezTerm Shell #6756

DevX-Cipher avatar Mar 06 '25 10:03 DevX-Cipher

You can do this without using nilshell press windows +r and enter notepad and paste the following according to your path

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\WezTerm Here] @="Open WezTerm Here" "Icon"="C:\Program Files\WezTerm\wezterm-gui.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\WezTerm Here\command] @=""C:\Program Files\WezTerm\wezterm-gui.exe" start --cwd "%V""

save the file as a .reg file it will give you the option to merge this with the register(click yes)

if it doesnt give you the option by default go to where you saved the file and double click it , now you will get a 2 popups ,just click yes and it will work for you

Image

now you can go in any folder and yu will get open wezterm here as an option

ThunderBolt975 avatar Jun 23 '25 07:06 ThunderBolt975

the new windows 11 context menu can open be done using IExploreerCommand in msix package

DevX-Cipher avatar Jun 23 '25 07:06 DevX-Cipher

I just think think the other method is simpler but yeah ,in the end just do whatever works for your pc and is convenient tou you

ThunderBolt975 avatar Jun 23 '25 07:06 ThunderBolt975