I have an interactive fzf bash script that puts my choice into the X clipboard, like so:
#!/bin/bash
cat /path/to/file.txt | fzf | xclip -sel p -sel s -sel c
exit 0
The text file contains some lines:
one
two
three
four
five
If I launch the script from within a terminal emulator manually: bash path/to/script.sh, then xclip permanently stores piped content and it is available to paste even after closing the terminal emulator.
However, I want to bind it to a keyboard shortcut within my DE to use on demand, so I need to use it with a terminal emulator command, like: mate-terminal -x bash /path/to/script.sh. It opens fine, but as soon as it terminates after making my choice, the xclip content is lost and not available anymore to paste. If I delay the script's termination with sleep 5, then while the terminal is still open, pasting piped content works, but as soon as it terminates, it is lost.
I need a way for the X clipboard to keep the content even after the terminal emulator closes.
fzf.