I would like to be able to select text in a file and have it sent to an external terminal. Is this possible?
If not, could it be done via applescript?
I would like to be able to select text in a file and have it sent to an external terminal. Is this possible?
If not, could it be done via applescript?
I ended up writing my own extension to do this using AppleScript. It was as simple as this:
function activate(context) {
const runIterm = vscode.commands.registerCommand('run-external.iterm', function() {
const editor = vscode.window.activeTextEditor;
let textToPaste;
if (editor.selection.isEmpty) {
textToPaste = editor.document.lineAt(editor.selection.active.line).text;
} else {
textToPaste = editor.document.getText(editor.selection);
}
exec(
`osascript ` +
` -e 'tell app "iTerm"' ` +
` -e 'set mysession to current session of current window' ` +
` -e 'tell mysession to write text "${textToPaste}"' ` +
` -e 'end tell'`
);
});
context.subscriptions.push(runIterm);
}
exports.activate = activate;