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:
@@ -13,7 +13,7 @@ These features couple the shell to specific external tools. Disabling
|
||||
spwin Kitty or WezTerm
|
||||
tab Kitty, WezTerm, or Konsole
|
||||
split Kitty or WezTerm
|
||||
hist fzf + wl-copy (Wayland clipboard)
|
||||
hist fzf + wl-copy or win32yank.exe (WSL2)
|
||||
logs fzf + ov; reads from ~/.terminal_history/
|
||||
upgrade paru or yay (Arch Linux only)
|
||||
WakaTime hook wakatime CLI and a configured API key
|
||||
|
||||
@@ -35,11 +35,14 @@ no fallback:
|
||||
- `systemd-inhibit` (`wake-lock`)
|
||||
- `zramctl` / `swapon` (`swapstat`)
|
||||
- `sbctl` and UEFI Secure Boot state (`sbver`)
|
||||
- `wl-copy` / `xclip` for clipboard access (`y`, `p`, `paste`, `hist`) —
|
||||
Wayland or X11 only, no `pbcopy`/`pbpaste` fallback
|
||||
- GNU coreutils flags such as `stat -c` and `numfmt` (`sudo-toggle`,
|
||||
`dng2avif`), which differ or don't exist under a BSD userland
|
||||
|
||||
Clipboard access (`y`, `p`, `paste`, `hist`) is the exception: it falls back
|
||||
through `wl-copy`/`wl-paste` (Wayland), `xclip` (X11), and `win32yank.exe`
|
||||
(WSL2), so it works on all three. There is still no `pbcopy`/`pbpaste`
|
||||
fallback for macOS.
|
||||
|
||||
**macOS** is not supported. `_fish_deps_detect_pm` does check for `brew`, but
|
||||
that alone does not make the functions above work — they have no macOS
|
||||
equivalent path today.
|
||||
@@ -47,10 +50,10 @@ equivalent path today.
|
||||
**Windows** is not supported. Fish itself has no native Windows build;
|
||||
upstream's own "Windows" install docs are Cygwin/WSL workarounds, not a real
|
||||
port. This config is not tested under WSL either. WSL2 runs a real Linux
|
||||
kernel and can run `systemd`, so basic shell use may work, but `zramctl`,
|
||||
`sbctl`, and Secure Boot state are meaningless inside a VM, and clipboard
|
||||
integration would need a WSL-specific path (`clip.exe`, `win32yank`) that
|
||||
does not exist here.
|
||||
kernel and can run `systemd`, so basic shell use may work; `zramctl`,
|
||||
`sbctl`, and Secure Boot state are still meaningless inside a VM, but
|
||||
clipboard integration works via `win32yank.exe` (see above) once it's
|
||||
installed on the Windows side and reachable through WSL interop.
|
||||
|
||||
**Assumed present on any Linux system this runs on:** `git`, `gpg`, `tar`,
|
||||
and GNU coreutils (for `stat`, `date`, `numfmt`). These are not tracked by
|
||||
|
||||
+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