Handle all 3 Selections
Smithx10 opened this issue · 4 comments
xclip provides the following flag:
-f, -filter
when xclip is invoked in the in mode with output level set to silent (the defaults), the filter option will cause xclip to print the text piped to standard in back to standard out unmodified
It allows for users to do the following: ( Which I need since I run in VMWare Workstation sometimes )
xclip -sel p -f | xclip -sel sec -f | xclip -sel c
You might be able to achieve this already with a combination of the --executable
and --flags
options.
By default, Clipper will use:
- On macOS, executable
pbcopy
and no flags: ie. it uses justpbcopy
. - On Linux, executable
xclip
and flags of-selection clipboard
: ie.xclip -selection clipboard
.
Note that it assumes one executable and one set of flags, which means that you can't pipe multiple invocations together. However, by setting the executable to bash
, you can pipe commands together and I think you can probably get it to do what you want; something like:
--executable bash
--flags "-c 'xclip -sel p -f | xclip -sel sec -f | xclip -sel c'"
These can be set in ~/.clipper.json
or passed on the command-line as described in the README.md.
Let me know if that works.
Didn't work
The reason it doesn't work is that whatever you pass in via --flags
just gets split on whitespace into arguments; it isn't doing a proper parse, so it is as though you had run bash
with args -c
, 'xclip
, -sel
, p
, -f
, |
, xclip
, -sel
, sec
, -f
, |
, xclip
, -sel
, c'
, and that obviously won't work.
I don't have xclip locally, but I did an analogous test with:
# In one window:
clipper --executable=bash --flags="-c 'cat | cat | pbcopy'" --logfile=/dev/stdout --address=127.0.0.1
# In another:
echo message | nc localhost 8377
Workaround is to make a helper script and call that instead:
#!/bin/sh
# In your case, this would be your piped xclips...
cat | cat | pbcopy
Just say you save this at $HOME/code/clipper/helper.sh
, and chmod +x
it to make it executable.
Then:
clipper --executable=$HOME/code/clipper/helper.sh --flags="" --logfile=/dev/stdout --address=127.0.0.1
Works for me.