How to run any command in another terminal window?
Example: I opened one terminal window and if I run command like apropos editor
, then it run and out-puts on that window. But I want to run same command on another terminal window (new window) instead on present window from first terminal.
Further clarification:
I need suggest-command <command>
that open new terminal window and run mentioned <command>
in that (newly opened) window. (where suggest-command
is example of suggestion of command.)
How to do that?
This might be what you run:
In older versions, -e and -x were used:
It opens gnome-terminal with your last command (
!!
) executed and it stays open with the command output in the shell, even with an interactive command liketop
orless
...In your case its:
or in older versions:
Each terminal is even a program that you can launch as any other program, with
&
to put in background, giving a list of arguments and so on.Which terminal to use it depends first from the availability of the system that you are using (if they are installed or not), after from their peculiarity and then from your personal taste.
Note the differences between
-hold
ofxterm
and--hold
ofkonsole
.Each realization has different options that you have to check with the help. Even the help can be invoked in different way. You can find that
man konsole
doesn't function and so you have to ask directly to the executable with--help
.This is a list of terminal you can search on your system
Start another instance of whatever terminal is it you want to run:
Note the
-hold
. Most terminals will exit after running the command you feed them. There are already a dozen or so questions about this on the site:An alternative to that is to use an application which needs to be exited.
nano
will stay open on its own. If you're just outputting to screen, you could pipe it intoless
:That said, in your case (as the other two have said) it does seem easier that you just open another terminal and run your command.
After Ubuntu 18.04 LTS, you may want to switch from
-e
to--
, i.e.gnome-terminal -e
tognome-terminal --
because-e
and-x
are both deprecated.You could use the
-e
option to gnome-terminal as follows:Here
sh
is the shell that gnome-terminal opens. Note that this will exit the terminal as soon as the command has terminated. Refer to the manual page for gnome-terminal for more.Here goes my 50 cents with Terminator:
This also works, but I can't tell you the difference:
Note that script could also be a command.
Tested on Ubuntu 18.04 LTS.
So I know this is like 7 years late, but for anyone else seeing this it should still be helpful. I was having this exact problem too but found a solution that I think is better than what anyone else has suggested.
Per
man gnome-terminal
you can just executegnome-terminal -- sh -c '<your command>'
The
-- sh
allows it to run actual scripts instead of applications, so it would be just like typing it into a normal window. The only thing to note about this solution though is that the terminal will quit after the command is done executing.Hope this helps!