feat(clipboard): add win32yank fallback for WSL2
y, p, paste, and hist now try win32yank.exe after wl-copy/wl-paste and xclip, so clipboard access works under WSL2 once win32yank is installed and reachable through WSL interop. Updates the OS compatibility docs accordingly.
This commit is contained in:
+7
-2
@@ -12,7 +12,8 @@
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Searches fish history interactively using fzf, inserts the selected command
|
||||
# into the command line, and copies it to the clipboard via wl-copy.
|
||||
# into the command line, and copies it to the clipboard via wl-copy (falls
|
||||
# back to win32yank on WSL2).
|
||||
#
|
||||
# EXIT STATUS
|
||||
# 0 Command selected and inserted, or fzf was cancelled
|
||||
@@ -36,7 +37,11 @@ function hist --description 'Search fish history and put it in the prompt'
|
||||
# Strip the timestamp for the final output
|
||||
set -l command (echo $selected | string replace -r '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} ' '')
|
||||
|
||||
echo $command | wl-copy 2>/dev/null
|
||||
if type -q wl-copy
|
||||
echo $command | wl-copy 2>/dev/null
|
||||
else if type -q win32yank.exe
|
||||
echo $command | win32yank.exe -i --crlf 2>/dev/null
|
||||
end
|
||||
commandline -r $command
|
||||
end
|
||||
end
|
||||
|
||||
+5
-3
@@ -8,8 +8,8 @@
|
||||
# p [args...]
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Outputs clipboard contents to stdout. Uses wl-paste on Wayland,
|
||||
# falls back to xclip on X11. Supports -h/--help for usage info.
|
||||
# Outputs clipboard contents to stdout. Uses wl-paste on Wayland, xclip on
|
||||
# X11, or win32yank on WSL2. Supports -h/--help for usage info.
|
||||
#
|
||||
# ARGUMENTS
|
||||
# -h, --help Show usage help
|
||||
@@ -47,8 +47,10 @@ function p --description 'Put from clipboard'
|
||||
set paste_cmd wl-paste
|
||||
else if type -q xclip
|
||||
set paste_cmd xclip -selection clipboard -o
|
||||
else if type -q win32yank.exe
|
||||
set paste_cmd win32yank.exe -o --lf
|
||||
else
|
||||
echo "Error: No clipboard provider (wl-paste or xclip) found." >&2
|
||||
echo "Error: No clipboard provider (wl-paste, xclip, or win32yank) found." >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
# paste [args...]
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Outputs clipboard contents to stdout. Uses wl-paste on Wayland,
|
||||
# falls back to xclip on X11.
|
||||
# Outputs clipboard contents to stdout. Uses wl-paste on Wayland, xclip on
|
||||
# X11, or win32yank on WSL2.
|
||||
#
|
||||
# ARGUMENTS
|
||||
# args... Arguments forwarded to the clipboard tool
|
||||
@@ -28,8 +28,10 @@ function paste --description 'Paste from clipboard'
|
||||
wl-paste $argv
|
||||
else if type -q xclip
|
||||
xclip -selection clipboard -o $argv
|
||||
else if type -q win32yank.exe
|
||||
win32yank.exe -o --lf $argv
|
||||
else
|
||||
echo "Error: Neither wl-paste nor xclip found." >&2
|
||||
echo "Error: No clipboard provider (wl-paste, xclip, or win32yank) found." >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
+5
-3
@@ -8,8 +8,8 @@
|
||||
# y [text...]
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Copies text to the system clipboard using wl-copy (Wayland) or xclip (X11).
|
||||
# Reads from stdin when no arguments are given.
|
||||
# Copies text to the system clipboard using wl-copy (Wayland), xclip (X11),
|
||||
# or win32yank (WSL2). Reads from stdin when no arguments are given.
|
||||
#
|
||||
# ARGUMENTS
|
||||
# text Text to copy; reads from stdin if omitted
|
||||
@@ -42,8 +42,10 @@ function y --description 'Yank to clipboard'
|
||||
set copy_cmd wl-copy
|
||||
else if type -q xclip
|
||||
set copy_cmd xclip -selection clipboard
|
||||
else if type -q win32yank.exe
|
||||
set copy_cmd win32yank.exe -i --crlf
|
||||
else
|
||||
echo "Error: No clipboard provider (wl-copy or xclip) found." >&2
|
||||
echo "Error: No clipboard provider (wl-copy, xclip, or win32yank) found." >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user