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

Using fish shell, I've defined the following function in ~/.config/fish/functions/foo.fish:

function foo
    echo $argv
end

Quick test in a new fish shell shows that fish has picked up the function:

$ foo bar
bar

In my vifmrc file, I've defined the following filetype handler:

filetype *.txt foo %f | less 

If I now attempt to open a test.txt, I'd expect less to open with the contents test.txt since I've used the %f macro.

I found an old zsh issue regarding aliases, but the shellcmdflag option wont do me much good since the following works just fine:

$ fish -c 'foo test'
test

Or am I misunderstanding how vifm invokes commands in the context of filetype handlers?

1 Answer

0 votes
by
selected by
 
Best answer

Use this instead:

filetype *.txt echo -n; foo %f | less 

vifm attempts to be smart and check for existence of commands, which works fine unless it's something like an alias. A way to control this behaviour will need to be added eventually, to avoid such situations.

by

Works great, thanks.

Don't think I can mark this answer as accepted since I posted without an account, sadly.

...