2016-05-24 19:17:03 +08:00
|
|
|
function fish_clipboard_copy
|
2018-11-26 00:32:25 +08:00
|
|
|
# Copy the current selection, or the entire commandline if that is empty.
|
|
|
|
set -l cmdline (commandline --current-selection)
|
2019-05-05 19:33:35 +08:00
|
|
|
test -n "$cmdline"; or set cmdline (commandline)
|
2016-11-28 13:27:22 +08:00
|
|
|
if type -q pbcopy
|
2018-11-26 00:32:25 +08:00
|
|
|
printf '%s\n' $cmdline | pbcopy
|
2019-10-24 17:41:16 +08:00
|
|
|
else if set -q WAYLAND_DISPLAY; and type -q wl-copy
|
|
|
|
printf '%s\n' $cmdline | wl-copy
|
2016-05-24 19:17:03 +08:00
|
|
|
else if type -q xsel
|
2018-04-26 05:10:58 +08:00
|
|
|
# Silence error so no error message shows up
|
|
|
|
# if e.g. X isn't running.
|
2018-11-26 00:32:25 +08:00
|
|
|
printf '%s\n' $cmdline | xsel --clipboard 2>/dev/null
|
2018-06-03 04:53:02 +08:00
|
|
|
else if type -q xclip
|
2018-11-26 00:32:25 +08:00
|
|
|
printf '%s\n' $cmdline | xclip -selection clipboard 2>/dev/null
|
2016-05-24 19:17:03 +08:00
|
|
|
end
|
|
|
|
end
|