In bash, echo toast | xclip -sel c
saves the toast inside the clipboard, even when I close the terminal. Why does this seem to be non-persistent from other shells?
python3.5:
import os
os.system("echo toast | xclip -sel c")
Does the job, but when I press CtrlC, the clipboard is empty. A simple CtrlD does not clear the clipboard / works fine.
tclsh:
exec /bin/echo toast | xclip -sel c
Even keeps the process open, so I have to terminate it.
Is this a bug? How is this even possible? Or what am I misunderstanding?
Edit. cannot find a solution for this. I made a wish
(Tcl/Tk)-script, included a exec /bin/echo toast | xclip -sel c
line and closed the window. The clipboard is now empty. I tried -display, but both display and xauthority are set properly. The same problems were occuring with pythons pyperclip and xerox.
Edit2. the issue can be reduced to this question: https://unix.stackexchange.com/questions/316715/xclip-works-differently-in-interactive-and-non-interactive-shells and there does not seem to be a good alternative other than using xsel -ib
for storing clipboards.
try to continue pipeline or redirect output. For me its work in tcl:
exec printf "%s" $var | xclip -selection c | echo
or:
exec printf "%s" $var | xclip -selection c > /dev/null