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.

Should filetype and fileviewer options do work reliably on Cygwin?

0 votes
asked Oct 29 in vifm by Alik
edited Oct 29 by xaizek

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
answered Oct 29 by xaizek

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?

commented Oct 30 by Alik

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.

commented Oct 30 by xaizek

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.

commented Oct 31 by Alik

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.

commented Oct 31 by xaizek

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.

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.
...