I am trying to answer this other question: Command/script to start a terminal, enter text but don't execute.... I want to start the terminal and add specific text to it without executing, thus allowing me to copy some other variable text to it before executing. It's like when pasting
sudo apt install mpv into terminal without space at the end: the command will not start, but allow for example to add other programs to be installed.
I have come close to a solution with
xsel, which can send a command to terminal with a shortcut.
The commands to be used can be something like
bash -c "xsel -ib <<< 'MY_TEXT'"
bash -c "xsel -p <<< 'MY_TEXT'"
Thus, I can send that text to clipboard with one shortcut, open terminal with another shortcut, then paste what
xsel has copied to clipboard.
The problem is that the
xsel command sends to clipboard the text with a space or Enter at the end
MY_TEXT instead of
It's like the difference between
sudo apt install mpv which automatically runs the installation command and
sudo apt install mpv that waits for me to press enter.