[PR #6100] [MERGED] Add a context menu entry to "Open Windows Terminal here" #26584

Open
opened 2026-01-31 09:16:58 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/6100
Author: @zadjii-msft
Created: 5/21/2020
Status: Merged
Merged: 5/28/2020
Merged by: @undefined

Base: masterHead: dev/migrie/f/shell-extension


📝 Commits (10+)

  • c67b606 Lets just start by adding a new project
  • d2aab9e I guess this implements a COM interface?
  • f314d90 I'm not sure what I did wrong
  • f5fdae7 okay yea I missed this
  • 1d6b017 my dude it works
  • 1851535 Well this works to pop up a cmd window
  • 44c7da6 turns out it's real important to restart explorer.exe
  • 3c59824 Lots of polish
  • 643125f Use a magic static to compute if this should be the dev build or not
  • ad69e3f cleanup for review

📊 Changes

22 files changed (+580 additions, -11 deletions)

View changed files

📝 .github/actions/spell-check/dictionary/apis.txt (+7 -0)
📝 .github/actions/spell-check/dictionary/microsoft.txt (+1 -0)
📝 .github/actions/spell-check/expect/expect.txt (+2 -0)
📝 .github/actions/spell-check/expect/web.txt (+2 -0)
📝 .github/actions/spell-check/patterns/patterns.txt (+1 -1)
📝 OpenConsole.sln (+26 -0)
📝 src/cascadia/CascadiaPackage/CascadiaPackage.wapproj (+2 -0)
📝 src/cascadia/CascadiaPackage/Package-Dev.appxmanifest (+24 -1)
📝 src/cascadia/CascadiaPackage/Package-Pre.appxmanifest (+20 -1)
📝 src/cascadia/CascadiaPackage/Package.appxmanifest (+20 -1)
src/cascadia/ShellExtension/OpenTerminalHere.cpp (+211 -0)
src/cascadia/ShellExtension/OpenTerminalHere.h (+51 -0)
src/cascadia/ShellExtension/PlaceholderType.cpp (+10 -0)
src/cascadia/ShellExtension/PlaceholderType.h (+37 -0)
src/cascadia/ShellExtension/PlaceholderType.idl (+21 -0)
src/cascadia/ShellExtension/WindowsTerminalShellExt.def (+4 -0)
src/cascadia/ShellExtension/WindowsTerminalShellExt.vcxproj (+68 -0)
src/cascadia/ShellExtension/dllmain.cpp (+33 -0)
src/cascadia/ShellExtension/packages.config (+4 -0)
src/cascadia/ShellExtension/pch.cpp (+4 -0)

...and 2 more files

📄 Description

Summary of the Pull Request

image

I went with the simple option - just open the Terminal with the default profile in the selected directory. I'd love to add another entry for "Open Terminal here with Profile...", but that's going to be follow-up work, once we sort out pulling the Terminal Settings into their own dll.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

This adds a COM class that implements IExplorerCommand, which is what lets us populate the context menu entry. We expose that type through a new DLL that is simply responsible for the shell extension, so that explorer doesn't need to load the entire Terminal just to populate that entry.

The COM class is tied to the application through some new entries in the manifest. The Clsid values are IMPORTANT - they must match the UUID of the implementation type. However, the Verb in the manifest didn't seem important.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/6100 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 5/21/2020 **Status:** ✅ Merged **Merged:** 5/28/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/migrie/f/shell-extension` --- ### 📝 Commits (10+) - [`c67b606`](https://github.com/microsoft/terminal/commit/c67b606353e12073164ba1c5d4248fe7c71de543) Lets just start by adding a new project - [`d2aab9e`](https://github.com/microsoft/terminal/commit/d2aab9ea11bd10b45c71b3a5e030c1380680aacb) I guess this implements a COM interface? - [`f314d90`](https://github.com/microsoft/terminal/commit/f314d90a3d9961eaee29c35bebdcb2790d26b4bf) I'm not sure what I did wrong - [`f5fdae7`](https://github.com/microsoft/terminal/commit/f5fdae7eea1fe13b5933c6e1e8ad9d7aeabcc4fc) okay yea I missed this - [`1d6b017`](https://github.com/microsoft/terminal/commit/1d6b017ecdf5cacd217ae424b53d972e698cc648) my dude it works - [`1851535`](https://github.com/microsoft/terminal/commit/18515357aeeb706e74a1085b8245868eaf63b87c) Well this works to pop up a cmd window - [`44c7da6`](https://github.com/microsoft/terminal/commit/44c7da6b1adeed3380c7612f267c975f9ba8d505) turns out it's real important to restart explorer.exe - [`3c59824`](https://github.com/microsoft/terminal/commit/3c598249d4e337b5b3ebd7b9827522518215b0d0) Lots of polish - [`643125f`](https://github.com/microsoft/terminal/commit/643125f914dbb0ca51719e56c4a347b2dcca15d1) Use a magic static to compute if this should be the dev build or not - [`ad69e3f`](https://github.com/microsoft/terminal/commit/ad69e3f69c3b20a12879ed25d4f5237ceb7efd2e) cleanup for review ### 📊 Changes **22 files changed** (+580 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spell-check/dictionary/apis.txt` (+7 -0) 📝 `.github/actions/spell-check/dictionary/microsoft.txt` (+1 -0) 📝 `.github/actions/spell-check/expect/expect.txt` (+2 -0) 📝 `.github/actions/spell-check/expect/web.txt` (+2 -0) 📝 `.github/actions/spell-check/patterns/patterns.txt` (+1 -1) 📝 `OpenConsole.sln` (+26 -0) 📝 `src/cascadia/CascadiaPackage/CascadiaPackage.wapproj` (+2 -0) 📝 `src/cascadia/CascadiaPackage/Package-Dev.appxmanifest` (+24 -1) 📝 `src/cascadia/CascadiaPackage/Package-Pre.appxmanifest` (+20 -1) 📝 `src/cascadia/CascadiaPackage/Package.appxmanifest` (+20 -1) ➕ `src/cascadia/ShellExtension/OpenTerminalHere.cpp` (+211 -0) ➕ `src/cascadia/ShellExtension/OpenTerminalHere.h` (+51 -0) ➕ `src/cascadia/ShellExtension/PlaceholderType.cpp` (+10 -0) ➕ `src/cascadia/ShellExtension/PlaceholderType.h` (+37 -0) ➕ `src/cascadia/ShellExtension/PlaceholderType.idl` (+21 -0) ➕ `src/cascadia/ShellExtension/WindowsTerminalShellExt.def` (+4 -0) ➕ `src/cascadia/ShellExtension/WindowsTerminalShellExt.vcxproj` (+68 -0) ➕ `src/cascadia/ShellExtension/dllmain.cpp` (+33 -0) ➕ `src/cascadia/ShellExtension/packages.config` (+4 -0) ➕ `src/cascadia/ShellExtension/pch.cpp` (+4 -0) _...and 2 more files_ </details> ### 📄 Description ## Summary of the Pull Request ![image](https://user-images.githubusercontent.com/18356694/82586680-94447680-9b5d-11ea-9cf1-a85d2b32db10.png) I went with the simple option - just open the Terminal with the default profile in the selected directory. I'd love to add another entry for "Open Terminal here with Profile...", but that's going to be follow-up work, once we sort out pulling the Terminal Settings into their own dll. ## References * I'm going to need to file a bunch of follow-ups on this one. - We should add another entry to let the user select which profile - We should add the icon - I've got to do it in `dllname.dll,1` format, which is annoying. - These strings should be localized. - Should this only appear on <kbd>Shift</kbd>+right click? Probably! However, I don't know how to do that. * [A Win7 Explorer Command Sample](https://github.com/microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/winui/shell/appshellintegration/ExplorerCommandVerb) which hasn't aged well * [cppwinrt tutorial](https://docs.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/author-coclasses) on using COM in cppwinrt * [This is PowerToys' manifest](https://github.com/microsoft/PowerToys/blob/d2a60c7287eb5667b5282a519c92b759664c9e30/installer/MSIX/appxmanifest.xml#L53-L65) and then [their implementation](https://github.com/microsoft/PowerToys/blob/d16ebba9e0f06e7a0d41d981aeb1fd0a78192dc0/src/modules/powerrename/dll/PowerRenameExt.cpp) which were both helpful * [This ](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-extensions#instructions) was the sample I followed for how to actually set up the manifest, with the added magic that [`desktop5` lets you specify "Directory"](https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-desktop5-itemtype) ## PR Checklist * [x] Closes #1060 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments This adds a COM class that implements `IExplorerCommand`, which is what lets us populate the context menu entry. We expose that type through a new DLL that is simply responsible for the shell extension, so that explorer doesn't need to load the entire Terminal just to populate that entry. The COM class is tied to the application through some new entries in the manifest. The Clsid values are IMPORTANT - they must match the UUID of the implementation type. However, the `Verb` in the manifest didn't seem important. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:16:58 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26584