How to write a shell script to open four terminals and execute a command in each?
You could use a "for" loop, and a "&" to run xterm in background:
#!/bin/bash
# some older test, doesn't work and complains and I get this message on command line: "QApplication::qAppName: Please instantiate the QApplication object first"
# I also can't enter text after command executes
#echo "Hello World!"
#exec konsole --noclose -e cat ~/.aliases
for i in 1 2 3 4
do
# opens terminal but then I can't control terminal afterwards
xterm -hold -e "echo Hello My World" &
done
# didn't do anything
#exit 0
# didn't do anything except make me type exit an extra time where I executed my shell script
#$SHELL
Is there a way to launch a terminal window (or cmd on Windows) and pass/run a command?
Here is a working example showing how to open a Terminal window at a specific path (~/Desktop for instance) on macOS
, from a renderer script:
const { app } = require ('electron').remote;
const atPath = app.getPath ('desktop');
const { spawn } = require ('child_process');
let openTerminalAtPath = spawn ('open', [ '-a', 'Terminal', atPath ]);
openTerminalAtPath.on ('error', (err) => { console.log (err); });
It should be easy to adapt it to any selected atPath...
As for running other commands, I haven't found a way yet...
And here is the equivalent working code for Linux Mint Cinnamon
or Ubuntu
:
const { app } = require ('electron').remote;
const terminal = 'gnome-terminal';
const atPath = app.getPath ('desktop');
const { spawn } = require ('child_process');
let openTerminalAtPath = spawn (terminal, { cwd: atPath });
openTerminalAtPath.on ('error', (err) => { console.log (err); });
Please note that the name of the terminal application may be different, depending on the Linux flavor (for instance 'mate-terminal'
on Linux Mint MATE
), and also that the full path to the application can be explicitly defined, to be on the safe side:
const terminal = '/usr/bin/gnome-terminal';
HTH...
How to kill all open terminals using command lines in CentOs
If you want to kill all open terminals except for the current one, you can use
kill $(pgrep bash)
pgrep bash
lists the pids of all the active terminals
if the terminals refuse to die, you can use
kill -9 $(pgrep bash)
the "-9" is used to send the SIGKILL Signal to the process
How can I open the terminal in Visual Studio?
Visual Studio 2022/2019
Now Visual Studio has a built-in terminal:
Menu View → Terminal (Ctrl + ")
To change the default terminal
Menu Tools → Options → Terminal → Set As Default
Before Visual Studio 2019
From comments, the best answer is from Hans Passant.
Add an external tool.
Menu Tools → External Tools → Add
Title: Terminal (or name it yourself)
Command =
cmd.exe
or Command =powershell.exe
Arguments =
/k
Initial Directory =
$(ProjectDir)
Menu Tools → Terminal (or whatever you put in title)
Enjoy!
Related Topics
Maximum Java Heap Size of a 32-Bit Jvm on a 64-Bit Os
Best Way to Convert an Arraylist to a String
When Exactly Is It Leak Safe to Use (Anonymous) Inner Classes
Bitmap Size Exceeds Vm Budget Error Android
How to Deserialise a Subclass in Firebase Using Getvalue(Subclass.Class)
Tomcat 7: How to Set Initial Heap Size Correctly
Connecting to Access Database from Linux
Create a Shell Script to Run a Java Program on Linux
Match Multiline Text Using Regular Expression
Deserialize a List≪T≫ Object With Gson
Convert JSON Array to Normal Java List
How Delete a Collection or Subcollection from Firestore
How to Check If a File Is Open by Another Process (Java/Linux)