Open terminal and run command, from the command line [duplicate]












0
















This question already has an answer here:




  • Script to open terminal and show the output of the running commands

    1 answer



  • Launch terminal from bash and run program?

    1 answer




I am looking for a way to launch a terminal session from the command line on Ubuntu, something like this:



#/usr/bin/env bash

terminal -c 'node server.js'


if there is some cross-platform tool that also works on MacOS that'd be nice.



So I tried this:



gnome-terminal -- 'echo "foo" | bash'


and I got this:



enter image description here



And when I try this:



gnome-terminal --tab -- echo 'ts-node /home/oleg/codes/typeaware/doc-gen/lang/typescript/api/src/.test/express.test.ts' | bash


nothing happens, the gnome-terminal never opens.










share|improve this question















marked as duplicate by George Udosen, muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 15 '18 at 1:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















  • The correct command would be gnome-terminal -- sh -c 'echo "foo"; bash' or gnome-terminal -- bash -c 'echo "foo"; bash'

    – Terrance
    Dec 15 '18 at 4:18


















0
















This question already has an answer here:




  • Script to open terminal and show the output of the running commands

    1 answer



  • Launch terminal from bash and run program?

    1 answer




I am looking for a way to launch a terminal session from the command line on Ubuntu, something like this:



#/usr/bin/env bash

terminal -c 'node server.js'


if there is some cross-platform tool that also works on MacOS that'd be nice.



So I tried this:



gnome-terminal -- 'echo "foo" | bash'


and I got this:



enter image description here



And when I try this:



gnome-terminal --tab -- echo 'ts-node /home/oleg/codes/typeaware/doc-gen/lang/typescript/api/src/.test/express.test.ts' | bash


nothing happens, the gnome-terminal never opens.










share|improve this question















marked as duplicate by George Udosen, muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 15 '18 at 1:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















  • The correct command would be gnome-terminal -- sh -c 'echo "foo"; bash' or gnome-terminal -- bash -c 'echo "foo"; bash'

    – Terrance
    Dec 15 '18 at 4:18
















0












0








0









This question already has an answer here:




  • Script to open terminal and show the output of the running commands

    1 answer



  • Launch terminal from bash and run program?

    1 answer




I am looking for a way to launch a terminal session from the command line on Ubuntu, something like this:



#/usr/bin/env bash

terminal -c 'node server.js'


if there is some cross-platform tool that also works on MacOS that'd be nice.



So I tried this:



gnome-terminal -- 'echo "foo" | bash'


and I got this:



enter image description here



And when I try this:



gnome-terminal --tab -- echo 'ts-node /home/oleg/codes/typeaware/doc-gen/lang/typescript/api/src/.test/express.test.ts' | bash


nothing happens, the gnome-terminal never opens.










share|improve this question

















This question already has an answer here:




  • Script to open terminal and show the output of the running commands

    1 answer



  • Launch terminal from bash and run program?

    1 answer




I am looking for a way to launch a terminal session from the command line on Ubuntu, something like this:



#/usr/bin/env bash

terminal -c 'node server.js'


if there is some cross-platform tool that also works on MacOS that'd be nice.



So I tried this:



gnome-terminal -- 'echo "foo" | bash'


and I got this:



enter image description here



And when I try this:



gnome-terminal --tab -- echo 'ts-node /home/oleg/codes/typeaware/doc-gen/lang/typescript/api/src/.test/express.test.ts' | bash


nothing happens, the gnome-terminal never opens.





This question already has an answer here:




  • Script to open terminal and show the output of the running commands

    1 answer



  • Launch terminal from bash and run program?

    1 answer








command-line bash gnome-terminal gnome-shell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 15 '18 at 0:45







Alexander Mills

















asked Dec 15 '18 at 0:32









Alexander MillsAlexander Mills

1381114




1381114




marked as duplicate by George Udosen, muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 15 '18 at 1:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by George Udosen, muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 15 '18 at 1:15


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • The correct command would be gnome-terminal -- sh -c 'echo "foo"; bash' or gnome-terminal -- bash -c 'echo "foo"; bash'

    – Terrance
    Dec 15 '18 at 4:18





















  • The correct command would be gnome-terminal -- sh -c 'echo "foo"; bash' or gnome-terminal -- bash -c 'echo "foo"; bash'

    – Terrance
    Dec 15 '18 at 4:18



















The correct command would be gnome-terminal -- sh -c 'echo "foo"; bash' or gnome-terminal -- bash -c 'echo "foo"; bash'

– Terrance
Dec 15 '18 at 4:18







The correct command would be gnome-terminal -- sh -c 'echo "foo"; bash' or gnome-terminal -- bash -c 'echo "foo"; bash'

– Terrance
Dec 15 '18 at 4:18












1 Answer
1






active

oldest

votes


















2














Your initial command, gnome-terminal -- 'echo "foo" | bash', attempts to run a program named literally echo␣"foo"␣|␣bash, which you most likely don't have on your system.



The correct syntax would be gnome-terminal -- sh -c 'echo "foo" | bash', but it would not help, unless you actually have an executable named foo. You can see that the syntax is correct by trying



gnome-terminal -- sh -c 'echo "date; sleep 2" | bash'


But this is just a very complicated way of saying



gnome-terminal -- bash -c 'date; sleep 2'


As for the intended command, it probably should be



gnome-terminal --tab -- bash -c 'ts-node /home/oleg/codes/typeaware/doc-gen/lang/typescript/api/src/.test/express.test.ts'





share|improve this answer
























  • thanks, yeah these work well, one problem remaining is when I use ctrl-c the terminal window closes, I want to keep it open and drop into the shell after killing the process originally run. I tried a few things like gnome-terminal -- bash -c 'cmd && bash' but doesn't always work.

    – Alexander Mills
    Dec 15 '18 at 2:25











  • I am also looking to add the command to the bash history. I can add it to the bash history with history -s 'cmd' but it's not showing up in the history when I hit the up arrow when using the history -s command in my gnome-terminal command.

    – Alexander Mills
    Dec 15 '18 at 2:26











  • This will trap the SIGINT, but it fails to add the command to bash history gnome-terminal -- bash -c 'history -s cmd; trap bash SIGINT; cmd;

    – Alexander Mills
    Dec 15 '18 at 2:45




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Your initial command, gnome-terminal -- 'echo "foo" | bash', attempts to run a program named literally echo␣"foo"␣|␣bash, which you most likely don't have on your system.



The correct syntax would be gnome-terminal -- sh -c 'echo "foo" | bash', but it would not help, unless you actually have an executable named foo. You can see that the syntax is correct by trying



gnome-terminal -- sh -c 'echo "date; sleep 2" | bash'


But this is just a very complicated way of saying



gnome-terminal -- bash -c 'date; sleep 2'


As for the intended command, it probably should be



gnome-terminal --tab -- bash -c 'ts-node /home/oleg/codes/typeaware/doc-gen/lang/typescript/api/src/.test/express.test.ts'





share|improve this answer
























  • thanks, yeah these work well, one problem remaining is when I use ctrl-c the terminal window closes, I want to keep it open and drop into the shell after killing the process originally run. I tried a few things like gnome-terminal -- bash -c 'cmd && bash' but doesn't always work.

    – Alexander Mills
    Dec 15 '18 at 2:25











  • I am also looking to add the command to the bash history. I can add it to the bash history with history -s 'cmd' but it's not showing up in the history when I hit the up arrow when using the history -s command in my gnome-terminal command.

    – Alexander Mills
    Dec 15 '18 at 2:26











  • This will trap the SIGINT, but it fails to add the command to bash history gnome-terminal -- bash -c 'history -s cmd; trap bash SIGINT; cmd;

    – Alexander Mills
    Dec 15 '18 at 2:45


















2














Your initial command, gnome-terminal -- 'echo "foo" | bash', attempts to run a program named literally echo␣"foo"␣|␣bash, which you most likely don't have on your system.



The correct syntax would be gnome-terminal -- sh -c 'echo "foo" | bash', but it would not help, unless you actually have an executable named foo. You can see that the syntax is correct by trying



gnome-terminal -- sh -c 'echo "date; sleep 2" | bash'


But this is just a very complicated way of saying



gnome-terminal -- bash -c 'date; sleep 2'


As for the intended command, it probably should be



gnome-terminal --tab -- bash -c 'ts-node /home/oleg/codes/typeaware/doc-gen/lang/typescript/api/src/.test/express.test.ts'





share|improve this answer
























  • thanks, yeah these work well, one problem remaining is when I use ctrl-c the terminal window closes, I want to keep it open and drop into the shell after killing the process originally run. I tried a few things like gnome-terminal -- bash -c 'cmd && bash' but doesn't always work.

    – Alexander Mills
    Dec 15 '18 at 2:25











  • I am also looking to add the command to the bash history. I can add it to the bash history with history -s 'cmd' but it's not showing up in the history when I hit the up arrow when using the history -s command in my gnome-terminal command.

    – Alexander Mills
    Dec 15 '18 at 2:26











  • This will trap the SIGINT, but it fails to add the command to bash history gnome-terminal -- bash -c 'history -s cmd; trap bash SIGINT; cmd;

    – Alexander Mills
    Dec 15 '18 at 2:45
















2












2








2







Your initial command, gnome-terminal -- 'echo "foo" | bash', attempts to run a program named literally echo␣"foo"␣|␣bash, which you most likely don't have on your system.



The correct syntax would be gnome-terminal -- sh -c 'echo "foo" | bash', but it would not help, unless you actually have an executable named foo. You can see that the syntax is correct by trying



gnome-terminal -- sh -c 'echo "date; sleep 2" | bash'


But this is just a very complicated way of saying



gnome-terminal -- bash -c 'date; sleep 2'


As for the intended command, it probably should be



gnome-terminal --tab -- bash -c 'ts-node /home/oleg/codes/typeaware/doc-gen/lang/typescript/api/src/.test/express.test.ts'





share|improve this answer













Your initial command, gnome-terminal -- 'echo "foo" | bash', attempts to run a program named literally echo␣"foo"␣|␣bash, which you most likely don't have on your system.



The correct syntax would be gnome-terminal -- sh -c 'echo "foo" | bash', but it would not help, unless you actually have an executable named foo. You can see that the syntax is correct by trying



gnome-terminal -- sh -c 'echo "date; sleep 2" | bash'


But this is just a very complicated way of saying



gnome-terminal -- bash -c 'date; sleep 2'


As for the intended command, it probably should be



gnome-terminal --tab -- bash -c 'ts-node /home/oleg/codes/typeaware/doc-gen/lang/typescript/api/src/.test/express.test.ts'






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 15 '18 at 1:11









AlexPAlexP

7,56011529




7,56011529













  • thanks, yeah these work well, one problem remaining is when I use ctrl-c the terminal window closes, I want to keep it open and drop into the shell after killing the process originally run. I tried a few things like gnome-terminal -- bash -c 'cmd && bash' but doesn't always work.

    – Alexander Mills
    Dec 15 '18 at 2:25











  • I am also looking to add the command to the bash history. I can add it to the bash history with history -s 'cmd' but it's not showing up in the history when I hit the up arrow when using the history -s command in my gnome-terminal command.

    – Alexander Mills
    Dec 15 '18 at 2:26











  • This will trap the SIGINT, but it fails to add the command to bash history gnome-terminal -- bash -c 'history -s cmd; trap bash SIGINT; cmd;

    – Alexander Mills
    Dec 15 '18 at 2:45





















  • thanks, yeah these work well, one problem remaining is when I use ctrl-c the terminal window closes, I want to keep it open and drop into the shell after killing the process originally run. I tried a few things like gnome-terminal -- bash -c 'cmd && bash' but doesn't always work.

    – Alexander Mills
    Dec 15 '18 at 2:25











  • I am also looking to add the command to the bash history. I can add it to the bash history with history -s 'cmd' but it's not showing up in the history when I hit the up arrow when using the history -s command in my gnome-terminal command.

    – Alexander Mills
    Dec 15 '18 at 2:26











  • This will trap the SIGINT, but it fails to add the command to bash history gnome-terminal -- bash -c 'history -s cmd; trap bash SIGINT; cmd;

    – Alexander Mills
    Dec 15 '18 at 2:45



















thanks, yeah these work well, one problem remaining is when I use ctrl-c the terminal window closes, I want to keep it open and drop into the shell after killing the process originally run. I tried a few things like gnome-terminal -- bash -c 'cmd && bash' but doesn't always work.

– Alexander Mills
Dec 15 '18 at 2:25





thanks, yeah these work well, one problem remaining is when I use ctrl-c the terminal window closes, I want to keep it open and drop into the shell after killing the process originally run. I tried a few things like gnome-terminal -- bash -c 'cmd && bash' but doesn't always work.

– Alexander Mills
Dec 15 '18 at 2:25













I am also looking to add the command to the bash history. I can add it to the bash history with history -s 'cmd' but it's not showing up in the history when I hit the up arrow when using the history -s command in my gnome-terminal command.

– Alexander Mills
Dec 15 '18 at 2:26





I am also looking to add the command to the bash history. I can add it to the bash history with history -s 'cmd' but it's not showing up in the history when I hit the up arrow when using the history -s command in my gnome-terminal command.

– Alexander Mills
Dec 15 '18 at 2:26













This will trap the SIGINT, but it fails to add the command to bash history gnome-terminal -- bash -c 'history -s cmd; trap bash SIGINT; cmd;

– Alexander Mills
Dec 15 '18 at 2:45







This will trap the SIGINT, but it fails to add the command to bash history gnome-terminal -- bash -c 'history -s cmd; trap bash SIGINT; cmd;

– Alexander Mills
Dec 15 '18 at 2:45





Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?