refactor(clipboard): share provider detection across y/p/paste/hist
Extracts _fish_clipboard_copy and _fish_clipboard_paste so the wl-copy/xclip/win32yank fallback chain lives in one place instead of four near-duplicates. hist now goes through the same chain, so it also gets the xclip (X11) fallback it was missing before, alongside win32yank on WSL2.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# SYNOPSIS
|
||||
# _fish_clipboard_copy
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Copies stdin to the system clipboard. Tries wl-copy (Wayland), then
|
||||
# xclip (X11), then win32yank.exe (WSL2).
|
||||
#
|
||||
# EXIT STATUS
|
||||
# 0 Text copied to clipboard
|
||||
# 1 No clipboard provider found
|
||||
#
|
||||
# EXAMPLE
|
||||
# echo "hello" | _fish_clipboard_copy
|
||||
function _fish_clipboard_copy --description 'Copy stdin to the system clipboard'
|
||||
if type -q wl-copy
|
||||
wl-copy
|
||||
else if type -q xclip
|
||||
xclip -selection clipboard
|
||||
else if type -q win32yank.exe
|
||||
win32yank.exe -i --crlf
|
||||
else
|
||||
echo "Error: No clipboard provider (wl-copy, xclip, or win32yank) found." >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user