Make clipboard support optional, with shell command escape hatch
Supersedes #110 Closes #84 Closes #119
This PR uses PR #110 to move the clipboard detection to a crate feature so it can be fully disabled, but it doesn't completely remove the copy actions.
Can be built using: cargo build --no-default-features
This PR also adds a command line option --clipboard-cmd CMD to be able to set an arbitrary shell command to use for copy actions as I requested in #119.
I tested this with the following commands:
$ ./target/debug/jless --clipboard-cmd 'cat > /tmp/clipboard' /path/to/a/file.json
In this case copy actions will send the copy target as input to cat > /tmp/clipboard.
And:
$ ./target/debug/jless /path/to/a/file.json
In this case copy actions will be disabled, with the error message:
Unable to access clipboard: No clipboard support, use --clipboard-cmd to set one
FYI I rebased this PR on latest main after 0.9.0 release, taking into account the new 'print' commands
I used to use @GPerry's patch from #110 locally. Now that main was updated to 0.9.0 I just did a pull & rebase over that branch. Came here to open a fresh PR and found @bew has already beaten me to it 🥇
@PaulJuliusMartinez Do you have any thoughts on this? Since the codebase already treats clipboard as a "feature", making it completely optional is the next logical step IMO. I disable clipboard simply because I can't get xcb library to link properly.
Having @bew's implementation is a bonus, since this works in tmux:
tmux set -g set-clipboard on
jless --clipboard-cmd 'tmux load-buffer -w -' filename.json
Too bad this has gone unnoticed for so long. Seems like jless is not really developed further anymore. Can only suggest others to take a look at fx which is similar but also has non-interactive filtering and clipboard-functionality just works (under Wayland, as well)
Thank you @cjk ; it's funny how sometimes we just bang our head against the wall!
I also have had a feeling that jless is no longer actively developed, and I knew about fx (and have it installed), but it didn't cross my mind to try it, and it "just works"!
Thank for reminding me 🙌