Is it possible to open a document by using the Windows 10's "open with" feature with a program that comes with Cygwin, e.g. Zathura?
This one with a Cygwin program.
First attempt: try to simply use the Cygwin program under Windows directly, i.e. the executable in C:\cygwin64\bin
(in case of the standard install path).
Regardless of the "open with" problem, directly opening a Cygwin program often doesn't work well except for the most simple programs (no login shell is run first!).
So, starting the Cygwin X server, setting the Windows system environment variable DISPLAY
(this gets passed through) to :0.0
, using "open with" on C:\book.pdf
and choosing C:\cygwin64\bin\zathura.exe
makes Zathura open the GUI window. But we get the error:
error: Unknown file type: 'cannot open `/cygdrive/c/Windows/system32/C:\book.pdf'
(No such file or directory)'
❓
Obviously, something goes wrong with the path here.
Second attempt: work around the problem by using a Windows shortcut with the target:
C:\cygwin64\bin\bash.exe -l -c 'zathura "`cygpath "$0"`"'
At least that works for drag and drop in the Windows explorer. But again not with "open with".
As a minimal example create a Windows shortcut emitpath.lnk
with the target:
C:\cygwin64\bin\bash.exe -l -c 'echo "`cygpath "$0"`" > out.path'
It works as expected again with dragging & dropping the document onto the shortcut: a file in the Cygwin home out.path
is created and the "cygwin-ified" path of the document is written into it. We got very close.
But, alas, with "open with" it does not work; nothing happens.
So how to use "open with" with a Cygwin program on Windows 10?
There must be an easier way than to create an executable wrapper.
$()
instead of back-ticks. They are easier. Then you will have to show us what close looks like.