1. Install the multi-command extension
This allows us to create a sequence of commands that can be used by a keybinding.
2. Add this snippet to your settings.json
"multiCommand.commands": {
"multiCommand.openFolderInTerminal": {
"interval": 10,
"label": "Open Explorer view folder in active terminal",
"sequence": [
"copyFilePath",
"terminal.focus",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "cd \"" }
},
"workbench.action.terminal.paste",
{
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\"" }
},
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u000D"
}
}
]
}
}
What this effectively does is to copy the path of the selected folder and send sequences of text to the terminal, as stated here. The quotes are escaped by \
and Enter
is sent by the newline unicode character \u000D
.
3. Add a keybinding to your keybindings.json
{
"command": "multiCommand.openFolderInTerminal",
"key": "ctrl+enter",
"when": "filesExplorerFocus && !inputFocus"
}
The value of the "command"
key has the same text as the one defined on the "multiCommand.commands"
object.
Top comments (0)