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.
+1 vote
in vifm by

Noticed, that if i use ,c that's shortcut to open my vifmrc file the behavior differs depending on if vifm started from shell of from either tmux or screen

In the first case it works as expected - opens my vifm rc file in editor,
in the latter case however it just open editor with no file.

I have default keymapping

nnoremap ,c :write | execute ':!vim $MYVIFMRC' | restart<cr>

and it's obvious thtat MYVIFM variable is undefined/empty.

I have a vague feeling it's somehow relates to the manner tmux runs/executes (sub)shell
But no enlightenment so far.

1 Answer

+1 vote
selected by
Best answer

Newer command that doesn't have the issue

Current (since 0.8.2) version of the binding is this:

nnoremap ,c :write | edit $MYVIFMRC | restart<cr>

It also accounts for 'vicmd' option, so is a better choice.

What's wrong with the old one

Another way of getting it fixed is to use %n macro to suppress using terminal multiplexer like this:

nnoremap ,c :write | execute ':!vim $MYVIFMRC %n' | restart<cr>

The reason it's needed is that environment variables are passed from process parents to their children and in the case of terminal multiplexers they are the parents. There are ways to change their environment too, but since it can potentially affect too many unrelated processes, only selected variables are propagated this way.

When :edit is used, vifm does the expansion locally and shell gets expanded path, but with :execute !... command is passed to terminal multiplexer without expansion of environment variables and it's done on their side where there is no $MYVIFMRC as you've discovered.


Explained nice way, thanks a lot!