Guake / guake

Drop-down terminal for GNOME
https://guake.github.io
GNU General Public License v2.0
4.45k stars 579 forks source link

How to execute a command in a tab that already exist ? #2264

Open fredmo opened 1 month ago

fredmo commented 1 month ago

guake -h -e COMMAND, --execute-command COMMAND Execute an arbitrary command in a new tab.

I am in the tab number 3 I want to run a command in another tab , how could I do ?

guake --select-tab=2 --execute-command="echo hello" This command is executing in a new tab

guake --select-tab=2 && echo "hello" , the echo arrive in the current tab ( number 3 )

Could you modify --execute-command to be executed in --select-tab if present

egmontkob commented 1 month ago

(I'm not a guake developer, just chiming in.)

--execute-command works pretty much by simulating that you pressed those keys on the keyboard, including a final Enter.

It's reasonably safe to do it when starting up a new terminal tab with your shell. There might be some tricky corner cases when this goes wrong (e.g. if your default shell is configured to interactively ask you a question at first startup) but in practice this is extremely rare.

Once that shell is open and running there, this operation becomes much more risky. You might have entered a partial command, the new command would be appended to (or inserted into) it, resulting in garbage. You may be running a text editor, the "command" being inserted there as text. You may be running any application where those letters of the desired command instead invoke menu operations or other actions, a lot of them in a row, nothing to do with the command you wished to execute, but causing lots of unwanted side effects that you'd have a hard time tracking down and undoing.

It would be a feature that causes minor additional convenience at its best, but allows you to easily shoot yourself in the foot at its worse.

fredmo commented 1 month ago

As ugly workaround :

in tab 1 : tmux new-session -s mysession

in tab 2: tmux send-keys -t mysession 'echo hello' C-m

I would declare an alias to overcharge : "guake --rename-tab" with "tmux new-session -s" , but it s ugly...