kutsan / zsh-system-clipboard

System clipboard key bindings for Zsh Line Editor with vi mode. It is similar to what `set clipboard=unnamed` does for vim.
GNU General Public License v3.0
140 stars 16 forks source link

Support WSL #32

Closed yofriadi closed 1 year ago

yofriadi commented 3 years ago

I notice that this plugin does not work on my WSL specifically WSL 2 but work in my macbook. Thankyou if you would provide this support.

doronbehar commented 3 years ago

What is WSL?

kutsan commented 3 years ago

We are not familiar with Windows Subsystem for Linux and since I don't have a Windows machine it would be hard to support without testing. Although, it may be easy by adding a new switch case statement like we're doing in below for macOS. The questions are what we are going to get from $OSTYPE and how are we going to get and set clipboard content via command-line.

https://github.com/kutsan/zsh-system-clipboard/blob/3df409852be3060a577e49e07ffd5825dbc92e8a/zsh-system-clipboard.zsh#L26-L34

yofriadi commented 3 years ago

hmm I do this on my vim config, even though I don't know what it is, will this help maybe

" WSL yank support
let s:clip = '/mnt/c/Windows/System32/clip.exe'
if executable(s:clip)
  augroup WSLYank
    autocmd!
    autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif
  augroup END
endif
disco0 commented 3 years ago

OSTYPE parameter should be linux- in WSL, should be able to match it on the existing linux glob and then check for WSL specific commands after—e.g. win32yank(.exe), clip(.exe), pwsh.exe.

As a temporary solution for WSL users—here's an xclip command replacement that operates on the Windows clipboard, it should be handled by the xclip case transparently based on the xclip detection code above.