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'"
or
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
It's MY_TEXT
instead of MY_TEXT
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.
printf '%s' "MY_COMMAND" | xsel -p && konsole --hold -e xsel -p
to get MY_COMMAND in terminal and wait for new input (like when pastingsudo apt install mpv
), I getMY_COMMAND \ No newline at end of selection
: I would like to get justMY_COMMAND
and be able to type/paste a path after that. – cipricus Apr 08 '21 at 15:51