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

WSL2 support #134

Closed
wisewtf opened this issue Jun 1, 2022 · 5 comments
Closed

WSL2 support #134

wisewtf opened this issue Jun 1, 2022 · 5 comments

Comments

@wisewtf
Copy link

wisewtf commented Jun 1, 2022

Hello,

I know Windows is not supported yet. But I tried to make it work on WSL2 nonetheless.

I'm stuck on this issue:

> the-way cp 2
openssl x509 -noout -text -in
Error: Can't open display: (null)
Snippet #2 copied to clipboard

This happens every time the-way tries to copy stuff to the SYSTEM clipboard. I'm assuming it's because wsl2 cannot do it natively. WSL2 can use Windows binaries tho, as specified here

I am unsure why it tries to use a display. I hope anyone can shed some light about this.

search seems to work properly. Altough with the cmdsave function, I get the same issue after I use search.

❯ the-way search
find <path> -name <file>
✔ path · .
✔ file · '*.a'
Error: Can't open display: (null)
Snippet #1 copied to clipboard

Please let me know if you need further testing.

@Ninjani
Copy link
Member

Ninjani commented Jun 1, 2022

Hi, thanks for the issue and testing.

Are you using the default copy command in the config? You should be able to see this in the copy_cmd field in the config file stored at the-way config get. You'd likely have to change this to the command in the link you mentioned - the default for linux is xclip (also described here) which would explain the error message.

The command is always run as copy_cmd <snippet text> so the cat x.txt | clip way won't work. Instead you could make a file with echo "${1:-/dev/stdin}" | clip.exe in it and then set the copy_cmd to point to this file.

Let me know if that works out, I don't currently have access to a Windows machine to check but I can find one if it doesn't

@wisewtf
Copy link
Author

wisewtf commented Jun 1, 2022

I am using the default configuration.

theme = 'base16-ocean.dark'
db_dir = '/home/wise/.local/share/the-way/the_way_db'
themes_dir = '/home/wise/.local/share/the-way/themes'
copy_cmd = 'xclip -in -selection clipboard'

I was about ready to apologize because I was able to make it work ONCE on my main desktop computer which is running the Windows Terminal Preview version on Windows 11, and earlier I tried on my work latop which has stable Windows Terminal and Windows 10.

After the first try with the-way cp 1, which put the snippet in the clipboard and I was actually able to paste it around... it stopped working.

All I did was try to create a snippet with variables and copy that from the search function. It COMPLETELY freezes the terminal and Windows doesn't even realize it is, it's like it's absolutely stuck.

So I thought it could be an issue with variables in snippets, but trying to replicate the first result didn't work either. Windows Terminal just freezes.

So... clip.exe works. I just can't figure out what you mean with 'you could make a file with echo "${1:-/dev/stdin}" | clip.exe.

You mean make an executable script with echo "${1:-/dev/stdin}" | clip.exe as contents and use the script's path as the configuration for copy_cmd ? Or do I have to just write a simple file with those contents and put that path in? or do I have to cat that file in the copy_cmd field?

EDIT 1:

It doeesn't just freeze the terminal. It freezes whatever I try to paste the clipboard in after the cp command. It's insane. I've never seen this happen.

EDIT 2:

the-way cp 2
/home/wise/clip.sh: line 3: /dev/stdin: Permission denied

I tried it with a script (with a bash shebang), I get permission denied. What exactly does calling 1:-/dev/stdin do?

@Ninjani
Copy link
Member

Ninjani commented Jun 2, 2022

Yeah I'm not super familiar with WSL2 but I don't think using xclip can work, the xwindow would need to be connected to Windows.

And yes, I meant an executable as you tried. It's just meant to take what's in stdin, echo it, and then pipe that to clip.exe (since for some reason clip.exe doesn't work without the pipe, as in clip.exe stuff_to_copy doesn't work) - is there a different way to define stdin on WSL2?

@Ninjani
Copy link
Member

Ninjani commented Jun 2, 2022

Had a chance to try it out on WSL2 - this should work:
make a script with

#!/bin/sh
echo "$(cat -)" | clip.exe

and set copy_cmd to ./myscript

@wisewtf
Copy link
Author

wisewtf commented Jun 2, 2022

Yep!

Works perfectly. Thank you very much for the support. This can be closed!

@Ninjani Ninjani closed this as completed Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants