2019-10-27 17:34:58 +00:00
|
|
|
function fish_clipboard_paste
|
2019-11-04 19:47:58 +00:00
|
|
|
set -l data
|
|
|
|
if type -q pbpaste
|
2022-10-11 18:19:21 +00:00
|
|
|
set data (pbpaste 2>/dev/null | string collect -N)
|
2019-11-04 19:47:58 +00:00
|
|
|
else if set -q WAYLAND_DISPLAY; and type -q wl-paste
|
2022-10-11 18:19:21 +00:00
|
|
|
set data (wl-paste -n 2>/dev/null | string collect -N)
|
2021-07-23 18:50:04 +00:00
|
|
|
else if set -q DISPLAY; and type -q xsel
|
2022-10-11 18:19:21 +00:00
|
|
|
set data (xsel --clipboard | string collect -N)
|
2021-07-23 18:50:04 +00:00
|
|
|
else if set -q DISPLAY; and type -q xclip
|
2022-10-11 18:19:21 +00:00
|
|
|
set data (xclip -selection clipboard -o 2>/dev/null | string collect -N)
|
2020-11-06 12:11:56 +00:00
|
|
|
else if type -q powershell.exe
|
2022-10-11 18:19:21 +00:00
|
|
|
set data (powershell.exe Get-Clipboard | string trim -r -c \r | string collect -N)
|
2019-11-04 19:47:58 +00:00
|
|
|
end
|
2019-10-27 17:31:35 +00:00
|
|
|
|
|
|
|
# Issue 6254: Handle zero-length clipboard content
|
2022-10-11 18:19:21 +00:00
|
|
|
if not string length -q -- "$data"
|
2019-10-27 17:31:35 +00:00
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
2022-10-11 18:19:21 +00:00
|
|
|
if not isatty stdout
|
|
|
|
# If we're redirected, just write the data *as-is*.
|
|
|
|
printf %s $data
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2024-03-30 15:10:12 +00:00
|
|
|
__fish_paste $data
|
2016-05-24 11:17:03 +00:00
|
|
|
end
|