microsoft / vscode

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

Filter the terminal input and output by plugins. #154770

Closed lonnywong closed 2 years ago

lonnywong commented 2 years ago

I want to write a plugin to filter the terminal input and output.

The input of the keystrokes go through the plugin, and then send to the server by the plugin.

The output of the server go through the plugin, and then send to the terminal view by the plugin.

My goal is to implement upload and download functionality.

For more information, check https://github.com/trzsz/trzsz.js .

meganrogge commented 2 years ago

You can use the terminal's onData API to get the input

You can write to the terminal using sendText

lonnywong commented 2 years ago

@meganrogge Thanks for your help.

I want to transfer files from the server to local. A program run in the server will send the file content, the plugin receive it and save to disk. Is there a way to make the terminal doesn't show the file content?

I want the plugin to be a filter, not just a subscriber.

Tyriar commented 2 years ago

You can use the terminal's onData API to get the input

I think @meganrogge was thinking of xterm.js' API, not VS Codes. There is no API for listening to terminal data for security and performance. @lonnywong I don't completely understand the problem you're trying to solve but it seems like a regular CLI tool would work?

VSCodeTriageBot commented 2 years ago

We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding, and happy coding!

lonnywong commented 2 years ago

@Tyriar If it's a local terminal, a CLI works. I did it with https://github.com/trzsz/trzsz-go

But, if it's a remote ssh, a CLI won't work since the terminal already run on the server.

lonnywong commented 2 years ago

I have wrote a plugin for tabby: https://github.com/trzsz/tabby-trzsz

Now I want to write a plugin for vscode terminal.

Maybe the tabby plugin will help to understand what I am trying to do.

About security, any plugin may do bad things, right? It only works for the user who installed the plugin.

Tyriar commented 2 years ago

Maybe the tabby plugin will help to understand what I am trying to do.

I'm still not sure why it isn't a regular CLI tool though?

About security, any plugin may do bad things, right? It only works for the user who installed the plugin.

Sure, but since users often input passwords into terminals the chance for misuse is much greater here.

lonnywong commented 2 years ago

I'm still not sure why it isn't a regular CLI tool though?

A CLI program run on the server, it reads the files and write to stdout. And a plugin run on local, it receives the server output and write to local disk.

If the user is using Remote-SSH plugin in vscode. The terminal can only execute CLI on the server. The CLI can't write files to local disk.

lonnywong commented 2 years ago

Sure, but since users often input passwords into terminals the chance for misuse is much greater here.

How about the plugin attach after the user logined?

lonnywong commented 2 years ago

My bad, I didn't mention Remote-SSH plugin before.

If we are not using Remote-SSH plugin, a CLI would work.

Tyriar commented 2 years ago

Ah ok, I see. Unfortunately we're not planning on opening up such an API as mentioned above though

lonnywong commented 2 years ago

It's all right. I'm just seeing if there's a chance to do it. Thanks for your reply.