-
Notifications
You must be signed in to change notification settings - Fork 11
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
RFE: Follow active file in existed terminal #9
Comments
It's a bit tough to do as the current working directory of the terminal is not tracked currently. It might be easier once more API is added to VS Code but right now this is definitely out of the scope of this extension. |
Actually @Frodox wanted to say that it would be nice to have an alternative option to send |
Actually I retract my statement, How would a feature like this work if there are multiple terminals in a single window? Do all of them follow the active file? |
@Tyriar here is my proposal for requested feature. It is very sad that is didn't find a way to do that without altering clipboard. The main idea in possibility of changing cwd of terminal depending on current file you're working on. 'use strict';
import * as vscode from 'vscode';
import path = require('path');
import copy_paste = require('copy-paste');
export function activate(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('terminalHere.cd', () => {
let editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
let document = editor.document;
if (!document) {
return;
}
let uri = document.uri;
if (!uri) {
return;
}
let dir = path.dirname(uri.fsPath);
copy_paste.copy(`cd "${dir}"\n`);
vscode.commands.executeCommand("workbench.action.terminal.paste");
});
context.subscriptions.push(disposable);
}
export function deactivate() {
} |
Oh I wouldn't want this to happen on any terminal, only the ones that are launched via the extension, you can then send text directly to them by keeping a reference to this terminal object vscode-terminal-here/src/extension.ts Line 24 in cc20d67
I'd still like to figure out the UX for what happens when multiple terminals are up before we go ahead with a PR though. |
It should behave like what |
@scriptum sounds good, I'll accept a PR similar to above that adds a new command 👍 |
@Tyriar I finished implementation but I have to ask a question about better implementation. I'm new in TS ans VS Code API and didn't find better way to sent text into active terminal except using a trick - copy necessary code into system clipboard and paste into terminal. Is there a way to get current active instance of integrated terminal and just use Furthermore in Linux |
@scriptum there's no way until microsoft/vscode#13267 is done |
I would be nice if VSCode provide API for that. Not sure that this is possible with extension. |
Yes there is no extension API for that, VS Code doesn't expose many ways to modify UI to keep the editor feeling lightweight even with many extensions. |
@Tyriar @scriptum I believe microsoft/vscode#13267 is done. What's next? |
It's still only a proposed API, can't use it yet in a shipped extension. |
I'm eagerly waiting for that addition. Surprised it doesn't come with stock VS Code, because it's pretty common in other IDEs, e.g. PyCharm, Eclipse, geany and even gedit. |
This extension is now deprecated, see #20 |
I have implemented a simple extension that sends |
Very useful feature --- is it hard to follow directory of active file in last active terminal?
Like by hotKey or permanently when file changed (as option) ?
The text was updated successfully, but these errors were encountered: