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.
|
2020-05-15 03:07:37 +08:00
|
|
|
set -l cmdline (commandline --current-selection | string collect)
|
|
|
|
test -n "$cmdline"; or set cmdline (commandline | string collect)
|
2016-11-28 13:27:22 +08:00
|
|
|
if type -q pbcopy
|
2020-04-21 13:24:20 +08:00
|
|
|
printf '%s' $cmdline | pbcopy
|
2019-10-24 17:41:16 +08:00
|
|
|
else if set -q WAYLAND_DISPLAY; and type -q wl-copy
|
2020-04-21 13:24:20 +08:00
|
|
|
printf '%s' $cmdline | wl-copy
|
2021-07-24 02:50:04 +08:00
|
|
|
else if set -q DISPLAY; and type -q xsel
|
|
|
|
printf '%s' $cmdline | xsel --clipboard
|
|
|
|
else if set -q DISPLAY; and type -q xclip
|
|
|
|
printf '%s' $cmdline | xclip -selection clipboard
|
2020-11-06 20:11:56 +08:00
|
|
|
else if type -q clip.exe
|
|
|
|
printf '%s' $cmdline | clip.exe
|
2016-05-24 19:17:03 +08:00
|
|
|
end
|
|
|
|
end
|