-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an action to "Open in File Explorer" #12859
Comments
It seems like this ought to be a feature of the shell.
What does that mean? Does it refer to some mechanism that already exists? |
I mean, theoretically, yea. This is super doable in the shell. I'm more tracking this as a sub-task of the right-click context menu, or as a trigger. We need an action internally to hook up the context menu entry.
Yea I'm talking about the |
That's pretty neat and works as advertized (along with Ctrl+Shift+d). It's the sort of thing I don't often want to do. Most likely, by the next time I want to duplicate a tab, I'll have forgotten about the keystroke (and this thread). Are there other benefits that could come from a shell using OSC9;9 to send a string to WT? Is OSC9;9 documented anywhere other then the tutorial you mentioned? I didn't find it in https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences. |
At the moment not really, but who knows what we might do with it in the future. Like, maybe #12863. OSC9;9 was originally authored by ConEmu so they've got slightly better docs https://conemu.github.io/en/ShellWorkDir.html |
That I already have in TCC (popup history and dirhistory). New TCCs use GUI windows for this by default and that doesn't work very well with WT because TCC has no clue where the command line interface window IS. So I use the older option to create the popups in the console screen buffer. I'm aware of another thread that deals with console apps creating windows. I'm in favor of any improvements on that front, in particular, getting such "popup" windows to have a position which is based on the position of WT's tab. As it is, can WT convey such information to conhost and, if so, can a console app get it? |
I'm interested in this as well. We can get the WT position with Any suggestions? I'm considering Here's what a potential handler in void TerminalPage::_HandleOpenInFileExplorer(const IInspectable& /* sender */,
const ActionEventArgs& actionArgs)
{
const auto focusedTab{ _GetFocusedTabImpl() };
if (focusedTab)
{
const auto workingDirectory = focusedTab->GetActiveTerminalControl().WorkingDirectory();
const auto validWorkingDirectory = !workingDirectory.empty();
if (validWorkingDirectory && _hostingHwnd.has_value())
{
LPRECT lpRect;
GetWindowRect(TerminalPage::_hostingHwnd.value(), lpRect);
// Spawn Explorer
}
}
} Quick update: spawning Explorer with I'm also lost on trying to add my handler to the Command Palette. It's registered as an action in the X-macros and I've been testing it through a Command in |
Wait hold up why do we need to do that at all? I think it's perfectly fine to just
Whoops, we should probably just delete that file - it's not actually used anymore 😅 |
Hmm. I definitely put it in
The keyboard shortcut works, but it still doesn't show up in command palette. Do I have to add it to another place? Side note, someone should really make a tutorial for registering an action to command palette. I'll open an issue for it when I finish figuring this one out. Thanks! |
Ah, probably. There's a pile of places you need to add this stuff, though, fewer than there used to be. I bet you're missing an entry in
You know, there actually is a guide, but it's pretty out of date: https://github.com/microsoft/terminal/blob/main/doc/cascadia/AddASetting.md#adding-an-action. We've since added some x-macros to the project that take care of a LOT of the boilerplate, but clearly not all of it. I might have you also refer to #12097 - looks like that was the most recent merged PR to add an action. That one also needed action args, which I don't think we need in this case, so that should simplify things a bit. |
If I'm understanding the OP correctly, then the following command will open a file manager at the current CLI working directory:
that is; launch Been using this for years (decades?), to great effect. I'm not sure what the equivalent for PowerShell syntax is. |
There's an actual shortcut which is ii (invoke-item). |
I made a commit 07ab3d9 to add this as an action, but I don't see it in the command palette. It works when I attach it to the right click fly out menu though. What am I missing? |
I believe it could be because you're missing an |
Thank you that fixed the problem. I made a PR. I saw in #13526 that the team believes actions related to CWD don't have too much value at the moment since most people don't path integration set up. Is there value in working on an action to open a highlighted directory instead? |
Kinda the opposite of the context menu. Open the CWD in file explorer. Trick here, shell needs to have been configured for path integration.
Maybe there's a way to make the action do nothing if the active Terminal hasn't set one?
Also relevant: #3337, #5916
Other thoughts: What if the user has a path selected? Check if that text is a path, that path exists, and if so, then open that path in explorer maybe?
The text was updated successfully, but these errors were encountered: