Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by
edited by

I noticed that filetype doesn't work reliably on Cygwin.

For example, consider the following piece of code:

if !has('win')
    filetype * xdg-open
else
    filetype * start, explorer
endif

While it works on Linux, it doesn't work on Cygwin.
What is strange, is that something like this

filetype *.zip zip -sf %c | less

works well on both Linux and Cygwin (given that Cygwin has zip installed).

Similarly,

fileviewer *.[ch],*.[ch]pp highlight -O xterm256 -s dusk --syntax c %c

does not seem to work on Cygwin, despite highlight utility working fine in the Cygwin terminal.

Am I missing something? Are there any special configuration that has to be done in order for filetype/fileviewer to work on Cygwin consistently?

1 Answer

0 votes
by

Yes, they should.

if !has('win')
While it works on Linux, it doesn't work on Cygwin.

On Cygwin has('win') is evaluated to false, maybe there is no xdg-open in Cygwin?

does not seem to work on Cygwin, despite highlight utility working fine in the Cygwin terminal.

Does it work if you do :!!command-here inside vifm?

by

On Cygwin has('win') is evaluated to false,

That was the issue (I thought it will be true and didn't check the actual value, my bad). Looks like both explorer and xdg-open work fine now.

Does it work if you do :!!command-here inside vifm?

It does. For example, if my vifmrc contains only
fileviewer *.c highlight -O xterm256 --syntax c %c
then :view on file test.c doesn't have highlighting.

However, highlight -O xterm256 --syntax c test.c does have highlighting.

by

While picking viewers, vifm checks for their existence, it could be that it somehow decides that highlight doesn't exist.

You could try using highlight.exe or prepending echo -n && to the command (echo should exist), at least as a workaround.

In my setup filetype *.c highlight -O ansi does work in Cygwin64 with highlight being installed outside Cygwin, so I don't really understand what's going on in your case.

by

Apparently the highlighting was missing because default TERM value of MinTTY in Cygwin is set to xterm. It can be changed to xterm-256color under "Options -> Terminal -> Type".

Not quite sure why even with TERM=xterm highlighting was working outside of Vifm, but given the apparent misconfiguration it is hardly a Vifm issue.

Thank you, xaizek.

by

Not quite sure why even with TERM=xterm highlighting was working outside of Vifm [...]

It's quite easy to explain. Terminal will handle escape codes if it knows them. Programs running on their own just output to terminal, but Vifm has to process output of a viewer and translate it to libcurses calls. Seeing TERM=xterm libcurses consults terminfo database and decides that at most 16 colors can be displayed. So highlighting was effectively stripped during translation phase.

...