microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.45k stars 28.62k forks source link

support reveal in finder when focus terminal #154917

Open tjx666 opened 2 years ago

tjx666 commented 2 years ago

terminal menu context:

image

And shortcut:

{
    "key": "alt+cmd+r",
    "command": "revealFileInOS",
    "when": "terminalFocus"
},

@Tyriar

Tyriar commented 2 years ago

@tjx666 what file/folder are you wanting to reveal?

tjx666 commented 2 years ago

@tjx666 what file/folder are you wanting to reveal?

just terminal current location, same with shell command pwd. With shell integrated, this info shoulud be access.

Tyriar commented 2 years ago

Good idea, will see if we can get to it for July

Tyriar commented 9 months ago

We could expose a few things here with the cwd similar to the explorer:

image

The context menu could have a section on external (OS or workbench component) integration, I'm thinking the following options:

Opening up for contributions, here are some steps to implement:


1: Create new commands that open explorer, OS explorer and external terminal based on the terminal's current working directory.

https://github.com/microsoft/vscode/blob/cb0ff849b874492a8783aacbe2d54147e8d11c3e/src/vs/workbench/contrib/terminal/browser/terminalActions.ts

These commands should support getting contextual instances via the getSelectedInstances2 function:

https://github.com/microsoft/vscode/blob/cb0ff849b874492a8783aacbe2d54147e8d11c3e/src/vs/workbench/contrib/terminal/browser/terminalActions.ts#L1623-L1639

2: Hook up the context menu entries to the TerminalInstanceContext and TerminalEditorInstanceContext menus

https://github.com/microsoft/vscode/blob/cb0ff849b874492a8783aacbe2d54147e8d11c3e/src/vs/workbench/contrib/terminal/browser/terminalMenus.ts#L90-L287

Support for InstanceContext may need to be added for this, see references to that symbol for how it works:

https://github.com/microsoft/vscode/blob/cb0ff849b874492a8783aacbe2d54147e8d11c3e/src/vs/workbench/contrib/terminal/browser/terminalContextMenu.ts#L17-L35

3: Hook up context menu entries to the TerminalTabContext menu

https://github.com/microsoft/vscode/blob/cb0ff849b874492a8783aacbe2d54147e8d11c3e/src/vs/workbench/contrib/terminal/browser/terminalMenus.ts#L555-L652

4: Create a shell integration active context key and make sure the commands are disabled when it's not active