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