How to run terminal commands on Theia startup?

I am trying to write an extension that opens a terminal and executes a script on startup. How do I do that?

I am using the code in the HelloWorld extension generated from the yo-generator.

This is what I currently have

However, only the terminal appears but without any input (“echo Test”) or any output.

[original thread by Zhang Bosen]

[Oleksandr Andriienko]

terminalWidget has method “sendText”. You can use it.

[Zhang Bosen]

Is this what you meant?

[Zhang Bosen]

[Zhang Bosen]

I tried it but it there is not output on the terminal. What I am looking for is something like this after theia startup.

[Zhang Bosen]

[Zhang Bosen]

It is something like gitpod’s auto configuration when you initially load into gitpod.

[Zhang Bosen]

sounds like a bug, that sendText does nothing

please open an issue

[Zhang Bosen]

I have opened an issue here: https://github.com/theia-ide/theia/issues/3929

[Nicholas Han]

Hi there, I’m looking to implement some terminal script commands but im not sure where to implement this code in.

@nicholasl00 Could you elaborate a bit more? Using sendText should be fine if you don’t need output. If you want to get output when you should use tasks or processes.

[Nicholas Han]

@anton-kosyakov i want to run a few commands on the terminal and get the returned output.

The returned output is a link to a novnc display, which i intend to parse it to the OpenURL in the command palette.

Specifically where/how should i implement this?

The issue is that terminal manipulates streams, where are no such concepts like tasks or commands. So i don’t think it is a proper API. I have not used this part of Theia often and not very familiar. On your place I would look into the process and task Theia extensions, sorry cannot give more help right now. @elaihau @paul-marechal maybe you can help to find a proper API to use