Open terminal and run command, from the command line
23,562
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'
Related videos on Youtube
Author by
Alexander Mills
Updated on September 18, 2022Comments
-
Alexander Mills over 1 year
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:
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.
-
Admin over 5 yearsThe correct command would be
gnome-terminal -- sh -c 'echo "foo"; bash'
orgnome-terminal -- bash -c 'echo "foo"; bash'
-
-
Alexander Mills over 5 yearsthanks, 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 over 5 yearsI 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 over 5 yearsThis 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;