Sample Header Ad - 728x90

How to avoid xsel sending text to clipboard with space/Enter at the end

1 vote
1 answer
475 views
I am trying to answer this other question: [Command/script to start a terminal, enter text but don't execute...](https://unix.stackexchange.com/q/644117/341192) . 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 enter image description here 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.
Asked by cipricus (1779 rep)
Apr 8, 2021, 02:31 PM
Last activity: Apr 8, 2021, 02:58 PM