devon2018/snippet

Add support for terminal snippets

Closed this issue · 4 comments

Add support for terminal snippets

Hello @devon2018

You can try send snippet to terminal

const vscode = require('vscode');

const snippet_command = "echo 1";
let hasTerminal = vscode.window.terminals.length;

if( ! hasTerminal )
{
  vscode.window.createTerminal({ name: 'Command' });
}

if (vscode.window.activeTerminal) {
	vscode.window.activeTerminal.show();
	vscode.window.activeTerminal.sendText(snippet_command);
}

Thanks @mean-cj

So i've started working on this feature in the last week, I will try and use the code you've given as much as possible, however vscode doesn't allow much interaction from the integrated terminal in terms of grabbing the highlighted text, so i'm still trying to find the best way to do that.

I think that's enough ,

user can create a snippet from highlighted text on editor.

normal click send snippet to editor or ctrl+click send to terminal
or can select "send to ..." on context menu in snippet dialog

It's easier for development


on vscode settings user can enable this option for copy highlight text to clipboard
"terminal.integrated.copyOnSelection" : true

so if you need enable context menu on terminal use
"terminal.integrated.rightClickBehavior": "default",

Support for terminal snippets has now been added in version 0.1.0.