Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/paste from wsl #1994

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions plugins/x2sel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - pbpaste (macOS)
# - termux-clipboard-get (Termux)
# - powershell (WSL)
# - cygwim's /dev/clipboard (Cygwin)
# - cygwin's /dev/clipboard (Cygwin)
# - wl-paste (Wayland)
# - clipboard (Haiku)
#
Expand All @@ -26,6 +26,9 @@ getclip () {
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
# Wayland
wl-paste
elif type powershell.exe >/dev/null 2>&1; then
# WSL
powershell.exe -noprofile -command Get-Clipboard | tr -d '\r'
elif type xsel >/dev/null 2>&1; then
# Linux
xsel -bo
Expand All @@ -38,9 +41,6 @@ getclip () {
elif type termux-clipboard-get >/dev/null 2>&1; then
# Termux
termux-clipboard-get
elif type powershell.exe >/dev/null 2>&1; then
# WSL
powershell.exe Get-Clipboard
elif [ -r /dev/clipboard ] ; then
# Cygwin
cat /dev/clipboard
Expand All @@ -52,9 +52,15 @@ getclip () {

CLIPBOARD=$(getclip)

if [ -z "$CLIPBOARD" ]; then
echo "No content in clipboard"
exit 1
fi

# Check if clipboard actually contains a file list
for file in $CLIPBOARD ; do
if [ ! -e "$file" ] ; then
echo "'$file' is not a file"
exit 1;
fi
done
Expand Down
Loading