Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
in vifm by

I want to have a Tmux popup window with FZF to search for a file from inside Vifm.

I have a custom .zsh script in ~/.config/vifm/scripts which gets the job done (works well if I hardcode server name) but fails if I try to pass the server name dynamically:

nnoremap f :!~/.config/vifm/scripts/vifm_fzf.sh "%d" "%{v:servername}" &<cr>

I do logging in my script and see that path is passed correctly but the server name is passed as literal: v:servername} which causes Sending remote commands failed.

I don't want to hardcode serve name becasue I want my script to handle multiple instances of Vifm well.

Please advice how to invoke a custom script with dynamic server name (I've tried some attempts with escape etc. but failed).

1 Answer

+1 vote
by
selected by
 
Best answer

The %{expression} syntax is specific to the 'statusline' option. A mapping could insert it via expression register (<c-r>=fnameescape(v:servername)<cr> in place of "%{v:servername}") or you could do

let $VIFM_SERVER_NAME = v:servername

in your vifmrc and then just use "$VIFM_SERVER_NAME".

by

Thanks for quick reply!

I went with:

nnoremap f :!~/.config/vifm/scripts/vifm_fzf.sh "%d" <c-r>=fnameescape(v:servername)<cr> &<cr>

and it works nicely!

by

I've put it all into a blog post: Vifm Fuzzy Find in tmux Popup Window with fzf and fd

by

Thanks for sharing the script and the interesting blog post.

One tiny improvement: you don’t have to specify the full path if you use the Vifm scripts directory.

So instead of

nnoremap f :!~/.vifm/scripts/vifm_tmux_fzf_fd_search.sh "%d" <c-r>=fnameescape(v:servername)<cr> &<cr>

you can use

nnoremap f :!vifm_tmux_fzf_fd_search.sh "%d" <c-r>=fnameescape(v:servername)<cr> &<cr>

The documentation explains this:

The $VIFM/scripts directory can contain shell scripts. vifm modifies its PATH environment variable to let user run those scripts without specifying full path. All subdirectories of the $VIFM/scripts will be added to PATH too. Script in a subdirectory overlaps script with the same name in all its parent directories.
by

Thanks, post updated!

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.
...