mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:54:04 +08:00
72fd328ad2
Ubuntu's fish package on WSL 1 has xsel as recommended dependency, even though there is no X server available. This change makes us use Windows' native clipboard even when xsel is installed.
17 lines
680 B
Fish
17 lines
680 B
Fish
function fish_clipboard_copy
|
|
# Copy the current selection, or the entire commandline if that is empty.
|
|
set -l cmdline (commandline --current-selection | string collect)
|
|
test -n "$cmdline"; or set cmdline (commandline | string collect)
|
|
if type -q pbcopy
|
|
printf '%s' $cmdline | pbcopy
|
|
else if set -q WAYLAND_DISPLAY; and type -q wl-copy
|
|
printf '%s' $cmdline | wl-copy
|
|
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
|
|
else if type -q clip.exe
|
|
printf '%s' $cmdline | clip.exe
|
|
end
|
|
end
|