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


In my Bash shell I have a lot of aliases and functions defined. Lots of those which I want to be able to call inside of vifm.

An example would be an fzf wrapper (which is a funcion defined in my ~/.bashrc) which I want to call instead of whatever is written in term() function here

So for example:

command! FZFfind :set noquickview | :execute 'goto' fnameescape(term('find | fzf --height 10 2>/dev/tty'))

Would then become:

command! FZFfind :set noquickview | :execute 'goto' fnameescape(term('my_fzf_wrapper_function 2>/dev/tty'))

How would I be able to do this specific example?

And in general? Would it be possible for vifm to get access to my (Bash) enviroment like that? If so, how?


1 Answer

0 votes


You might try writing a wrapper for your shell that preloads aliases
and commands and pointing 'shell' option at it. For this you'd have to extract part of your configuration into a separate file and source it from, say, '.bashrc'. The wrapper would also source the functions and aliases and run the command similar to:

source ~/.bash_aliases

Not sure if adding exec in front of `"$@" will work in all cases, so omitted it.


In my current ~/.bashrc the ~/.bash_aliases (with all aliases and functions I need) is sourced.

Did you mean the following?

Create some kind of wrapper with the code snippet you provided and put it somewhere like ~/.config/vifm/aliaswrapper.bash then I should put it in vifmrc like so:

shell ~/.config/vifm/aliaswrapper.bash

If I do that however and I :reload the config it gives an error that says "Trailing characters"


Yes, you got it right. The thing is that .bashrc isn't read by non-interactive shells.

You set an option as :set option=... (don't use ~ or $HOME for 'shell' as it won't be expanded). However, there seems to be a simpler way (this forces login mode of the shell, in which it also reads .bashrc):

set shellcmdflag=-lc

If your .bash_profile or .pfofile loads .bashrc, then it should be enough, otherwise use the wrapper.