Skip to content

Commit af9bfd3

Browse files
authored
Merge pull request #1994 from psicho2000/fix/paste-from-wsl
fix/paste from wsl
2 parents 9a128f1 + aae7d39 commit af9bfd3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

plugins/x2sel

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# - pbpaste (macOS)
99
# - termux-clipboard-get (Termux)
1010
# - powershell (WSL)
11-
# - cygwim's /dev/clipboard (Cygwin)
11+
# - cygwin's /dev/clipboard (Cygwin)
1212
# - wl-paste (Wayland)
1313
# - clipboard (Haiku)
1414
#
@@ -26,6 +26,9 @@ getclip () {
2626
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
2727
# Wayland
2828
wl-paste
29+
elif type powershell.exe >/dev/null 2>&1; then
30+
# WSL
31+
powershell.exe -noprofile -command Get-Clipboard | tr -d '\r'
2932
elif type xsel >/dev/null 2>&1; then
3033
# Linux
3134
xsel -bo
@@ -38,9 +41,6 @@ getclip () {
3841
elif type termux-clipboard-get >/dev/null 2>&1; then
3942
# Termux
4043
termux-clipboard-get
41-
elif type powershell.exe >/dev/null 2>&1; then
42-
# WSL
43-
powershell.exe Get-Clipboard
4444
elif [ -r /dev/clipboard ] ; then
4545
# Cygwin
4646
cat /dev/clipboard
@@ -52,9 +52,15 @@ getclip () {
5252

5353
CLIPBOARD=$(getclip)
5454

55+
if [ -z "$CLIPBOARD" ]; then
56+
echo "No content in clipboard"
57+
exit 1
58+
fi
59+
5560
# Check if clipboard actually contains a file list
5661
for file in $CLIPBOARD ; do
5762
if [ ! -e "$file" ] ; then
63+
echo "'$file' is not a file"
5864
exit 1;
5965
fi
6066
done

0 commit comments

Comments
 (0)