gnome-terminator / terminator

multiple GNOME terminals in one window
https://gnome-terminator.org
GNU General Public License v2.0
2.1k stars 252 forks source link

terminator -x <command> does not work if there's a Terminator window already open #739

Closed TyrasNistru closed 10 months ago

TyrasNistru commented 1 year ago

Describe the bug If there's no Terminator window opened, running terminator -x <command> will open a terminator window with <command> running. But if there's a Terminator window already open, nothing happens: no new window or tab is opened and no command is run. Same happens when running x-terminal-emulator -e when Terminator is the default terminal application.

To Reproduce

Expected behavior A new Terminator tab or window to open with the specified command running

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

nautics889 commented 1 year ago

Hello, @TyrasNistru

I couldn't reproduce the behaviour you've encounter on. Having almost same environment.

OS: Ubuntu "Jammy" 22.04.1 LTS on top of WSL Terminator: v2.1.3

Here what i did (correct me if i'm mistaken):

  1. Run terminator at first with command ./terminator & (& is just to start another one from this command line);
  2. Run terminator providing -x flag, e. g. with command ./terminator -x 'date; sleep 6'(sleep should be supplied for prevent terminal's quiting right after the command is executed);

The terminator's window has opened correctly at the second step and date command has been executed (and date output was displayed for 6 seconds).

Here is how it looks like: terminator_with_x_command

TyrasNistru commented 1 year ago

This way it works, but it seems that it's not the way some IDEs work.

I first noticed this with Qt Creator IDE, with the option to run the project in terminal.

If I set it to use tilix, it works as intended, but if I set to use terminator -x or x-terminal-emulator -e (with terminator being the default terminal emulator), it only works if there's no terminator window running.

mattrose commented 1 year ago

Hmm, this works for me on 2.1.3 as well. There were some bugs with parsing -e args that may not be fixed in 2.1.3, but -x works as expected. I have Tilix around too, can you give me an example of a command that works as expected in Tilix but not in terminator?

TyrasNistru commented 1 year ago

Sorry for taking too long to answer this. Domestic problems.

TBH, on the command line, I can't reproduce it either anymore. But the problem with the QtCreator IDE still persists. I don't know where the problem is anymore.

You can reproduce it (on Ubuntu Jammy at least), by using QtCreator and trying to run a project with the setting "run in terminal" enabled on your project settings.

If you change in settings below to use tilix instead of x-terminal-emulator, it works as intended. If you use as it is below, or change it to terminator and -x respectively, it will happens as I said in the issue description.

Screenshot from 2023-05-19 10-35-17

aplatypus commented 1 year ago

I ran across the reported behaviour for this issue using the remotinator command to open a tab. I did a few tests with terminator as shown above and the same result; nothing happened as if it didn't work.

While testing with the remotinator I discovered that "something" does happen but it appears as if there was not new tab. Here's what I found:

  1. The commands below were used to test the --execute option.
    • $ terminator -x touch abc
    • $ remotinator vsplit -x "touch xxx"
  2. In both cases the files "abc" and "xyz" were created and the command prompt returned.
  3. What is actually happening is that both command examples create a new terminal session; in a tab for terminator and a new split panel for the vsplit command.
  4. Then the command executes and finally
  5. The new tab or panel exits!
  6. So the appearance is just as if Nothing Happened.

I expect the panel or tab to Remain Open, if it doesn't open a tab/panel why would I use an open tab/panel command?

If I ever wanted to close the newly opened terminal I could issue an exit so closing the tab has no benefit.

Hope this helps this problem to get unravelled/resolved.


Versions ...

$ terminator -v; remotinator  -v
terminator 2.1.3
remotinator 2.1.3
$
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 23.04
Release:    23.04
Codename:   lunar
aplatypus commented 12 months ago

Hoping this assists others with objectives similar to mine. My use case: I want to perform something like:

$  terminator --new-tab  -x 'touch abc; touch XYZ; ls -l'
$ 
$ #   OR ... 
$ 
$  remotinator new_tab   -x 'touch abc; touch XYZ; ls -l'

... where the "new-tab" remains open as an interactive terminal just as if I'd only issued the appropriate command to open a new tab, either:

$  remotinator new_tab

or

 $  terminator --new-tab

... having executed the commands from the --execute option.


I believe this is one recipe ... Either of these commands work from a shell command line, either:

$ terminator --new-tab -x 'touch abc; ls -l; bash '

or

$ terminator -x 'touch abc; touch XXX; ls -l; alias; bash -i'

Each version leaves you with a new tab ready to work as if you had pressed Ctrl/Shift-T; with the extra advantage of having executed the preface commands in this case: "touch abc; ls". The ls command shows an abc file in the directory.

Finally the bash instruction leaves the new terminal tab or panel open and ready to work, with all the usual .bashrc settings and initialisation. The thing to note here is that the existing .bashrc contents can override what ever was done in the sequence of preface commands.

Credit for this approach goes to Peque from Stackoverflow:

I reckon that can assist people struggling with terminator v2 and the --command or --execute options can see a way forward. Good luck :four_leaf_clover: