Add support for copy and paste in WSL

- clip.exe is used to copy to the Windows clipboard
- There's no binary for pasting from the Windows clipboard so
  `Get-Clipboard` from powershell is used as a workaround. The
  superflous carriage return is stripped from the output.
This commit is contained in:
Ayooluwa Isaiah 2020-11-06 13:11:56 +01:00 committed by Fabian Homborg
parent 69ab68d856
commit ea1dffd53d
2 changed files with 4 additions and 0 deletions

View File

@ -12,5 +12,7 @@ function fish_clipboard_copy
printf '%s' $cmdline | xsel --clipboard 2>/dev/null
else if type -q xclip
printf '%s' $cmdline | xclip -selection clipboard 2>/dev/null
else if type -q clip.exe
printf '%s' $cmdline | clip.exe
end
end

View File

@ -8,6 +8,8 @@ function fish_clipboard_paste
set data (xsel --clipboard 2>/dev/null)
else if type -q xclip
set data (xclip -selection clipboard -o 2>/dev/null)
else if type -q powershell.exe
set data (powershell.exe Get-Clipboard | string trim -r -c \r)
end
# Issue 6254: Handle zero-length clipboard content