This removes our clipboard integration and replaces it with a set of explicit binding functions.
It should work on OSX via pbcopy/pbpaste (please test!) and on X11 via xsel.
I've explicitly not silenced the errors xsel throws when $DISPLAY is invalid so the user knows that it's not going to work.
This should fix #2894 and #2556 and provide a workaround for #2188.
kill: Remove xsel integration
Overwriting the user's clipboard by default is annoying and contributors
don't use it.
This is better served via an explicit binding that calls e.g. `xsel`.
docs: Remove section about clipboard integration
Add clipboard helper functions and bind them
\cy copies, \cv pastes.
Run fish_indent on default_key_bindings
I don't know if it's premature optimisation, but another option would be to use
if type -q pbcopy
commandline | pbcopy
else if type -q xsel
Yeah, this isn't performance-sensitive at all, and the bulk of the time is likely to be spent in the called command (xsel needs a trip to the X server and back).
Plus it would mean what you get via funced differs from the contents of the file and I like being able to use that for development. It's possible there's more tools to support here (there's also xclip, but I don't know if anything has it but not xsel), so it'd be nice to leave that possibility open.
Weirdly, the binding only seems to work every second time on OS X in iTerm 2:
A quick read didn't reveal any obvious problems. I was just about to tackle this myself. I've been pretty annoyed that every time I use my mouse to highlight and copy some text to paste into a command if I first do something like invoke the delete-word binding it replaces my explicit selection and I have to select that text a second time. So thanks for beating me to it. I'll test it in a couple of hours.
@zanchey: The weird need to press \cV twice is because the tty driver is in cooked mode and has "lnext = ^V". The fix is to undef that character like we already do for \cS (stop) and \cQ (start). In fact, we should undef all the characters except those for "kill", "susp", "intr", "quit" and "eof". I'll open an issue and fix that.
Other than the weird \cV behavior, which I'll fix in a separate change, this LGTM.
Merged with rebase as 2f51088..53c506f.
I notice there is no mention of pbcopy/pbpaste/xsel working out of the box - it's neat and should be noted in documentation.
@floam: f9edcbb mentions the bindings. Do you think we need more?
Nope. I missed that. Only noticed the documentation removal of the old stuff.