I have a jupyterlab extension that when you click on a dropdown menu, it will start a terminal and run a script. However, the terminal opens up in the background and the script does not run unless you go and click on the terminal yourself from the list of open tabs (the circle button on the left hand menu). How can I have the script run in the terminal without having to click on it? Also, how can I have the terminal open up in the main area as its own tab.
Here is the code that opens the terminal and runs the script:
const command: string = 'command:open';
app.commands.addCommand(command, {
label: 'Run Script In Terminal',
execute: async() => {
const manager = new TerminalManager();
await manager.ready;
displayPopUp1("Terminal will open now with script");
manager.startNew().then(session => {
bool = false;
session.send({
type: "stdin",
content: ['cd ~/path/to/script\n chmod +x script.sh\n yes | ./script.sh && exit\n']
});
session.disposed.connect(() => {
displayPopUp2("Script done running");
});
});
},
isEnabled: () => bool
});