guake icon indicating copy to clipboard operation
guake copied to clipboard

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

Open fredmo opened this issue 1 year ago • 1 comments

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

fredmo avatar Oct 15 '24 11:10 fredmo

(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.

egmontkob avatar Oct 22 '24 09:10 egmontkob

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...

fredmo avatar Oct 22 '24 19:10 fredmo

The ability to use the -e flag in an existing tab enables a security issue with enabling execution of commands in root authenticated shells from non-root processes and was intentionally removed. See CVE-2021-23556 for details. If you want to executed multiple commands in another tab, you may want to consider running a full script instead of single commands via -e

Davidy22 avatar Jan 06 '25 03:01 Davidy22