mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 18:03:37 +08:00
ea1dffd53d
- clip.exe is used to copy to the Windows clipboard - There's no binary for pasting from the Windows clipboard so `Get-Clipboard` from powershell is used as a workaround. The superflous carriage return is stripped from the output.
19 lines
752 B
Fish
19 lines
752 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 type -q xsel
|
|
# Silence error so no error message shows up
|
|
# if e.g. X isn't running.
|
|
printf '%s' $cmdline | xsel --clipboard 2>/dev/null
|
|
else if type -q xclip
|
|
printf '%s' $cmdline | xclip -selection clipboard 2>/dev/null
|
|
else if type -q clip.exe
|
|
printf '%s' $cmdline | clip.exe
|
|
end
|
|
end
|